Question

I need to regenerate a session using PHP, either by destroying the previous one or by any other possible solution. I am not a perfect PHP guy. The below work was done by a freelancer and now he is untraceable.

$ses="myses";
session_regenerate_id(false);
session_name($ses);
setcookie($ses, $_COOKIE[$ses], time()+10000, "/");
@session_start();
@ob_start();

I need to end the current session, and then start a new session.

Was it helpful?

Solution

session_start() // if it's not started already
session_regenerate_id()

This will regenerate a session id for you..if you want to destroy it, do something like:

session_start();
session_destroy();
session_start();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top