function MySessionClear() { //销毁所有的Session //这之后即使对$_SESSION变量存取,也不会影响其它PHP请求 MySessionStart(); session_unset(); session_destroy(); return true; }
function MySessionClear() { MySessionStart(); session_unset(); //释放所有$_SESSION变量,$_SESSION变为array() session_destroy(); //结束Session会话,删除Session文件,释放对应的SessionID //调用session_destroy函数后,对$_SESSION的任何操作,都将对其它PHP无效 //调用2次session_destroy函数会报错:session_destroy(): Trying to destroy uninitialized session }
* First, we update the cookie to have our (possibly new) session id. * Then we check if we need to remove the cookie and re-set it (in case they have finished a conversion, then continued browsing the site). * If we do need to re-set the cookie, we destroy the old session and re-start it. We may or may not get a new session id depending on the php version, that doesn't really matter. * If that's ok (we don't need to re-set the cookie), we don't need to do anything else. * * @see TPUtil::UpdateSessionCookie * @see TPUtil::RemoveCookie * @see MySessionStart */ if (isset($_COOKIE[TRACKPOINT_COOKIE_NAME])) { LogMessage(__FILE__, __LINE__, $ip, $trackpoint_sessionid, 'Cookie is set (' . $_COOKIE[TRACKPOINT_COOKIE_NAME] . ')', $userid); $TPUtil->UpdateSessionCookie($trackpoint_sessionid, $_COOKIE[TRACKPOINT_COOKIE_NAME]); if ($TPUtil->RemoveCookie($_COOKIE[TRACKPOINT_COOKIE_NAME], $trackpoint_sessionid)) { LogMessage(__FILE__, __LINE__, $ip, $trackpoint_sessionid, 'Cookie is set for removal', $userid); session_destroy(); MySessionStart(); $trackpoint_sessionid = session_id(); $neednewcookie = true; } if (!$neednewcookie) { exit; } } /** * Break up the url. We use special placeholders in the get string to mark whether it's a campaign, ppc or "other". */ $original_url = parse_url($landingpage); if (isset($original_url['query'])) { parse_str($original_url['query'], $urlparts); } else { $urlparts = array();