php Function Session_Regenerate_ID() - Function, Definition and Usage
Article about php function session_regenerate_id() - Function, Definition and Usage
Session handling is a way to make the data available across various pages of a web application. This is done using a unique ID which is passed from the server to the browser and then retrieved at every request from the same web page. This helps in minimizing the chances of Session hijacking. But one of the problems associated with this approach is that regenerating the session id at every request can cause unnecessary overhead as it requires the browser to send the new cookie with each request which may not always be possible.
This is why many developers use a function called session_regenerate_id() which replaces the current session id with a new one on each request without destroying any existing data. This can be used to avoid session fixation as well as to logout the user.
The problem is that this does not protect against session hijacking if the hacker has access to the cookies on the clients computer. In such cases the hacker can grab the old session id and hijack the existing web application. This is not very much different from stealing the passwords on a users computer.
So if you want to keep your site secure then it is better to regenerate the session id only when the level of authentication changes (such as when the user logs in or out). This will ensure that the hacker does not have access to the existing sessions. Also you need to make sure that your site uses SSL to prevent this type of hacking.