problem in cookies

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
Jay

Post by Jay » Tue Aug 20, 2002 1:38 pm

That's the nature of cookies, you can't use the cookie value in the same process as setting it. It's easier to think of it like this:

Step 1:
A user requests a page. The server sends a header code to set the cookie, then the rest of the page

Step 2:
User selects another page to view, or refreshes the page. At this time the browser will also send all cookie data

Step 3:
The server recieves the request for another page view, and also the cookie data. It parses the page, and uses the cookie data if need be

Step 4:
The resulting page is sent back to the user

The basic idea to remember is, to use a cookie value the browser has to send the cookie back to the server! Therefore by very function it can't be used in the same go as when you set it. In step one, the browser would have also sent any existing cookies, and the resulting page would have been dependant on these cookies too, depending on the script!

Post Reply

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest