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.

有帮助吗?

解决方案

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();
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top