-1
$a = session_id();
if(empty($a)) session_start();
$sid = session_id();

So i generate my session id with this three lines. It works perfect but i have a problem with reseting it. Can anyone give me a simple method on how to reset the current session_id and generate a new one?

  • are you looking for [session_destroy](http://php.net/manual/en/function.session-destroy.php) ? – Burki Jan 22 '16 at 11:35

2 Answers2

0

try this

session_start();

$old_sessionid = session_id();

session_regenerate_id();

$new_sessionid = session_id();

echo "Old Session: $old_sessionid<br />";
echo "New Session: $new_sessionid<br />";

print_r($_SESSION);
Gagan Upadhyay
  • 255
  • 2
  • 11
0

Did you try to use session_reset. http://php.net/manual/fr/function.session-reset.php

Maxime Limone
  • 121
  • 11