The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> max-age attribute not working, How do you make a cookie expire?
jmrathbun
post Jun 29 2011, 09:02 PM
Post #1


Newbie
*

Group: Members
Posts: 15
Joined: 8-June 11
Member No.: 14,726



I'm trying to set a cookie that will expire in 24 hours. I've tried
CODE
Set-Cookie: score=10; path=/; expires=time()+86400

and I've tried
CODE
Set-Cookie: score=10; path=/; max-age=86400

both on Unix and on Windows servers, but in every case I get a session cookie only.

What's wrong?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
 
Reply to this topicStart new topic
Replies
jmrathbun
post Jun 30 2011, 12:35 PM
Post #2


Newbie
*

Group: Members
Posts: 15
Joined: 8-June 11
Member No.: 14,726



Try testing my code, if you will. I've done it from this Perl script and with conventional HTML, and it always generates cookies. My question is, why are they session cookies rather than carrying the expiration date as the code requires? If you think it's the positioning that's at fault, how would you reposition this in the HTML? Please test your code before posting. Here's the output of the script:
CODE
Set-Cookie: topic=Consciousness; path=/; expires=time()+86400
Set-Cookie: score=10; path=/; max-age=86400
Set-Cookie: smarts=20; path=/; expires=time()+86400
Set-Cookie: playlevel=30; path=/; max-age=86400
Content-Type: text/html; charset=ISO-8859-1



<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>Set Cookie</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1>The cookie has been set!</h1>
</body>
</html>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 16th April 2024 - 10:05 AM