Answer the question
In order to leave comments, you need to log in
How to logout correctly?
Everything works well, but...
cookies are deleted only for the root folder of the site, if you then go to the subfolder of the project, cookies are written again for all pages.
<?php
include_once 'includes/functions.php';
sec_session_start();
// Unset all session values
$_SESSION = array();
// get session parameters
$params = session_get_cookie_params();
// Delete the actual cookie.
setcookie(session_name(),
'', time() - 42000,
$params["path"],
$params["domain"],
$params["secure"],
$params["httponly"]);
// Destroy session
session_destroy();
Setcookie("user_id",$_SESSION['user_id'],time()-3600000);
Setcookie("username",$_SESSION['username'],time()-3600000);
Setcookie("login_string",$_SESSION['login_string'],time()-3600000);
header("Location: ".$_SERVER['HTTP_REFERER']);
Answer the question
In order to leave comments, you need to log in
Something here is clearly too clever ... and cookies and sessions ...
Do you have your own cookies generated for each page?
//...
session_destroy();
Setcookie("user_id",$_SESSION['user_id'],time()-3600000);
//...
Do you have your own cookies generated for each page?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question