Question

I am working on an authentication library for my website, and I want to use a token based authentication system, but I don't have a clue how to generate a secure session token so that I could identify users. Does anyone have any resources that would point me in the right direction?

Was it helpful?

Solution

A random authentication token could be enough depending on the kind of architecture you have.

Or you could use GUIDs, ... There are a lot of possibilities, here is one:

When the user authenticates, generate a random token, add it into a cookie on the user system and into the database. When the user comes back, the unique random token is searched in the database so you can establish the link between the random token and the user. Tada !

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top