Why is the session not available after URL redirection?

Source: Internet
Author: User
Tags php write set cookie
Why is the session not available after URL redirection?
http://www.baidu.com/index.php write a session[' key ' at this time = 200;
Redirect to http://www.sian.com, http://www.sian.com redirect to
http://www.baidu.com/index.php, found session[' key ' will not be found??
Excuse me, why? Is there a cookie in this situation?

Reply content:

Why is the session not available after URL redirection?
http://www.baidu.com/index.php write a session[' key ' at this time = 200;
Redirect to http://www.sian.com, http://www.sian.com redirect to
http://www.baidu.com/index.php, found session[' key ' will not be found??
Excuse me, why? Is there a cookie in this situation?

Are you using server-side direct redirect? If so, there is a good chance that this problem will arise. Because the session should correspond to the cookie
client-->A(set session and redirect to B)-->B-->AThe first time you access a set cookie may not be saved to the user's browser, you receive a 302 redirect away, so return to a when there is no cookie to the corresponding session, of course, it may be redirected from B to a, because cross-domain, the request head does not have a domain cookie, So I can't get to the session.
So this redirect, is generally done separately to do a redirect page (JS or other way) do jump, rather than direct server-side redirect, reference microblogging, space and other sites have similar special redirect page

The program or the viewer? The browser's words are related to the settings of the service and the settings of the viewer.

The session can be preset at each redirect, which guarantees that the session will remain valid after each redirect.

  • 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.