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.