It is important to style the material you are quoting using >
, so it is obvious that the work is not yours.
As for citation, there is an official citation process if you are interested. The Chicago Manual of Style has many different descriptions of how to cite other people's work.
In my opinion, the closest official citation structure for Stack Overflow is the blog style (http://www.chicagomanualofstyle.org/tools_citationguide.html)
In the example post you list, this format would look like
Adi, Mon Nov 12 2018, Celeritas, "Generating an unguessable token for confirmation e-mails", Sep 20 '13 at 7:06, https://security.stackexchange.com/a/40314/
I like to reference these citations using a super script in the post, and a subscript at the footer. I edited your post to include the citation, feel free to roll back if you don't think it is inline with your intent.