Why is the SESSION unavailable after URL redirection? Www. baidu. comindex. php writes a SESSION [& #039; key & #039;] 200; redirects to www.sian.com, www.sian.com, and then redirects to www. baidu. comindex. php, found SE... why is the SESSION unavailable after URL redirection?
The http://www.baidu.com/index.php writes a SESSION ['key'] = 200;
Redirect to http://www.sian.com, http://www.sian.com then redirect
Http://www.baidu.com/index.php, found the SESSION ['key'] can not find ??
Why? Is there a COOKIE like this?
Reply content:
Why is the SESSION unavailable after URL redirection?
The http://www.baidu.com/index.php writes a SESSION ['key'] = 200;
Redirect to http://www.sian.com, http://www.sian.com then redirect
Http://www.baidu.com/index.php, found the SESSION ['key'] can not find ??
Why? Is there a COOKIE like this?
Are you using the server side for direct redirect? If yes, this problem may occur. Because the session corresponds to the cookie
client-->A(set session and redirect to B)-->B-->A
When you access A for the first time, the set Cookie may not be saved in the user's browser, and you will receive the 302 redirection, so when you return A, there will be no cookie for the corresponding session, of course, when B is redirected to A, the session is not obtained because the cookie in domain A is not found in the request header because of cross-domain conversion.
Therefore, this type of redirection generally involves a single redirection page (js or other methods) for redirection, instead of a direct server-side redirect. for details, refer to Weibo, space, and other websites that have similar dedicated redirect pages.
Program or browser? The browser is related to the service setting and the browser setting.
You can preset the session during each redirect operation to ensure that the session remains valid after each redirection.