Different path cookie with same name

Source: Internet
Author: User
A project that uses multiple cookies to jointly determine the user state
The background is as follows

UserID Usercode username

Three cookies, if they exist, determine if there is a session or delete the cookie prompting the user to log back in

At first I used JS to generate cookies later, because of other reasons instead of PHP generation, found during the testing process, in the login and the first page of the dead loop

Check the cookie situation, found that the previous use of JS generated by the time I tested the project ran under the subdirectory, so PHP did not remove them, after the experiment and Baidu learned

Multiple cookies with different paths of the same name
If the page is in the root directory, then get the directory below the
If the page is in a subdirectory, get the sub-directory

http://jinnianshilongnian.iteye.com/blog/1656534 here to know
Using the Java.net.HttpURLConnection tool/frame, if multiple cookies with the same name under the same path will get the first;
Use Apache HttpClient to get the last one as the browser behaves.

That means you get the latest cookie.

But I use IE and Google Browser test results for

Subdirectories below the page gets the sequence of cookies for the current directory and then gets the parent directory as soon as it gets to whatever time it takes to return. Did not follow the way to get the latest cookie

I wonder if, according to the logic of my project PHP can not know that the cookie obtained in the end is that directory can not delete this cookie, has been dead loop ... Solving


Reply to discussion (solution)

Different?? Is there any difference in the device?
For example:
When building a cookie (actiontype). In Firefox, when a cookie with the same name exists under/A, Firfox reads the cookie directly under/A, ignoring/under the cookie (that is, the parent path cookie). In other words, if the action of/A is empty, Firefox considers the action to be empty, regardless of the parent's cookie with the same name.

In contrast with IE, the cookie (action) in/under. When you read a cookie under/A, IE reads the parent cookie and the subpath cookie, even if the cookie under/A is empty, and the parent path cookie is the equivalent of reading it together. However, preference is given to path cookies.

Therefore, when we use cookies, we try to ensure that the server sets a cookie.

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