kdu*_*ubs 1 php cookies session
我正在尝试学习 PHP 并使用会话。我看到了有关在注销时使用 session_destroy 的示例,但我在 php 文档中看到了这一点:
为了完全终止会话,比如注销用户,会话 ID 也必须取消设置。如果使用 cookie 来传播会话 ID(默认行为),则必须删除会话 cookie。setcookie() 可用于此目的。
那么在注销时需要做什么?
在您刚刚引用的段落下方有一个回答您问题的示例:http : //php.net/manual/en/function.session-destroy.php
Example #1 使用 $_SESSION 销毁会话
Run Code Online (Sandbox Code Playgroud)<?php // Initialize the session. // If you are using session_name("something"), don't forget it now! session_start(); // Unset all of the session variables. $_SESSION = array(); // If it's desired to kill the session, also delete the session cookie. // Note: This will destroy the session, and not just the session data! if (ini_get("session.use_cookies")) { $params = session_get_cookie_params(); setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"] ); } // Finally, destroy the session. session_destroy(); ?>
| 归档时间: | 
 | 
| 查看次数: | 8650 次 | 
| 最近记录: |