Forum Moderators: DixonJones
I am redesigning an Intranet Site which means I know that all the PC's using it will accept cookies and I am using logon scripts to place usernames in a cookie and then this info can be used elsewhere in Intranet applications. This did work fine, but in my redesign i have decided to use another key in the cookie to store information about which background the user wants. The problem is that the cookie sometimes blanks after I close my browser. If I just set the username when I reopen the browser it is fine and remembers who I am but if I also set the background then when I reopen the browser it cannot retrieve the username or the background.
I believe I am using Keys correctly but i don't know whats going on?
Any ideas would be appreciated.
Thanks
Under ASP (I imagine PHP would work the same way) you can't actually modify a cookie in-place as HTTP only supports issuing and returning of entire cookies, not partial cookies.
Effectively by only setting a single attribute you are erasing your old cookie (since it has the same name as this new cookie) and creating a new cookie with only the b/g attribute set, also since you didn't set and expiry date this defaults to being a session cookie so it will expire as soon as your browser closes.
- Tony
I was setting the expirary date OK, however i DIDN'T know that you coudln't modify the cookie once you had created it. I was just altering the background variable and not setting the username again, but this should have left me with at least the background variable.
Thanks for the advice, i have changed it now to use 2 cookies and this works OK, but if i decide to use just the 1 again i'll know i have to set the whole thing rather than updating it - which obviously i can't do.
Cheers Dreamquick