Why is the SESSION unavailable after URL redirection?

Source: Internet
Author: User
Tags in domain
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-->AWhen 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.