Deleting session cookies with PHP
83
This is what I need to be doing: delete all session cookies and destroy the session on the server. delete the session cookie from the browser.
<?php
session_start();
$name = session_name();
$expire = strtotime('-1 year');
$params = session_get_cookie_params();
$path = $params['path'];
$domain = $params['domain'];
$secure = $params['secure'];
$httponly = $params['httponly'];
setcookie($name, '', $expire, $path, $domain, $secure, $httponly);
unset($_SESSION["course_code"]);
unset($_SESSION["course_name"]);
unset($_SESSION["publisher"]);
session_unset();
session_destroy();
?>
Does this properly do what needs to be done?
Answer
Solution:
Here you go, you need to delete in a loop:
PS: from PHP manual:
To be safe call
session_regenerate_id()
upon login, logout, and sensitive areas of the script.