0

I cannot properly unset the session id of my page unless I close the browser and reopen it. I tried to set the $_SESSION = null; and to forcefully set the cookie to a negative value setcookie('cookiename', '', time()-3600); but no results yet.

<body>

<?php
session_start();
// Unset all of the session variables.
$_SESSION = null;
setcookie('cookiename', '', time()-3600);
session_destroy();

print "SESSION has been destroyed - all session data deleted";
?>

back to home page

</body>
JohnSnow
  • 163
  • 4
  • 16

3 Answers3

0

replace lab5destroy.php with below code

<body>
<?php
ini_set('session.use_strict_mode', 1);
session_start();
// Unset all of the session variables.
session_regenerate_id();
session_destroy();
print "SESSION has been destroyed - all session data deleted";
?>
<hr>
<a href="http://localhost/lab5.php" rel="nofollow noreferrer">back to home page</a>
</hr>
</body>
0
session_start();
session_unset();
session_destroy();
Vbudo
  • 405
  • 4
  • 9
0

The fix was session_name() instead of 'cookiename'

JohnSnow
  • 163
  • 4
  • 16