Is there a way to overwrite a pre-existing cookie with new data but leave the expiry date?

Oct 19, 2000
17,860
4
81
I'm wanting the ability to overwrite a pre-existing cookie with completely different data and leave the expiry date. Is this possible?
 

Train

Lifer
Jun 22, 2000
13,576
72
91
www.bing.com
could you just read the current cookie (data and expiry)

then overwrite it (new data + copied expiry)

seems like it should work?
 
Oct 19, 2000
17,860
4
81
Originally posted by: Train
could you just read the current cookie (data and expiry)

then overwrite it (new data + copied expiry)

seems like it should work?

Guess I'll need to learn how to read the expiry date from a cookie. Thanks :).
 

clamum

Lifer
Feb 13, 2003
26,252
403
126
What are you using to interact with the cookie? Scripting language, I mean. I know in ASP.NET you can get/set a cookie's data without changing its ExpirationDate property.
 
Oct 19, 2000
17,860
4
81
Originally posted by: clamum
What are you using to interact with the cookie? Scripting language, I mean. I know in ASP.NET you can get/set a cookie's data without changing its ExpirationDate property.

My bad, I completely forgot to mention scripting language. PHP is my weapon of choice here.
 
Oct 19, 2000
17,860
4
81
Now that the long weekend is over and I'm back to work, I'd like to see if I can figure this out. Anybody know how to copy the expiry date from cookies in PHP?
 

Cerebus451

Golden Member
Nov 30, 2000
1,425
0
76
Originally posted by: blurredvision
Now that the long weekend is over and I'm back to work, I'd like to see if I can figure this out. Anybody know how to copy the expiry date from cookies in PHP?
From what I have read the expiration date is not sent from the browser to the server, only the name/value pairs. Most of the workarounds I saw were to put the expiration date into another cookie.

I haven't seen anything in PHP to set a cookie without altering the expiration date since leaving the expiration date from setcookie tells the cookie to expire with the session.
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
From using a packet sniffer more than I've really wanted to I can confirm that the Cookies header sent from the browser does not include the expiration date or the path of the cookie, just the name=value pair.