SESSION ID: Why does it need to be updated? SESSION ID: Why does it need to be updated? codeigniter codeigniter

SESSION ID: Why does it need to be updated?


it HAS to be updated frequently.

lets say YOU logged in to some online baking site. of course you have a unique session id for your session. BUT, if it is not frequently updated, someone could just take your session ID using some XSS tricks, plug your session id in to his browser and poof! he is logged in using your credentials!

and the server will never know that it wasn't you anymore who is accessing the site since he used your own session id.

http://en.wikipedia.org/wiki/Session_hijacking


The main reason is to prevent session hijacking. A list of ways to hijack sessions is in this wikipedia article. To prevent session fixation, this article is good.

By refreshing the session id often, any stolen session IDs would not be very useful for the attacker. In your example, it may take more than 5 minutes to steal the session id, after which, it is useless as it has been expired.

By stealing your session id, the attacker assumes your identity and can perform any action you are allowed to do.


One of the reasons to regenerate the session id is to prevent session hijacking.

Session hijacking is when a hacker get to know a user's session ID, and uses it to pretend he is that user.

See this PHP Security guide for more details.