简体   繁体   中英

how to unset session_cache_limiter in php

I have set session_cache_limiter('private_no_expire'); before session_start(); so that the user can use the Back button without 'Document Expired' page being shown. But now, I am unable to destroy the session and log the user out. What should I do to unset the session_cache_limiter ?

session_unset should work fine from my tests for clearing all the session variables.

Here is my login file (ie index.php) :

<?php
session_cache_limiter('private_no_expire');

session_start();

$_SESSION['test'] = true;

echo '<pre>';
print_r($_SESSION);
echo '</pre>';
?>

Here's the code I've tested it with (the logout file) :

<?php
session_cache_limiter('private_no_expire');
session_start();

session_unset();

echo '<pre>';
print_r($_SESSION);
echo '</pre>';
?>

The above code works for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM