views:

1155

answers:

2

I am trying to set a cookie in my Google App Engine page:

self.response.headers.add_header('Set-Cookie','CookieName=1234; expires:Sun, 31-May-2009 23:59:59 GMT; path=/;')

The expiration date is not showing up in the browser. So it deletes itself at the end of the session.

Here is the output from curl -D:

HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
Set-Cookie: CookieName=1234; expires:Fri, 01 Jan 2010 11:48:41 GMT
Date: Fri, 08 May 2009 11:57:25 GMT
Server: Google Frontend
Expires: Fri, 08 May 2009 11:57:25 GMT
Transfer-Encoding: chunked

What am I missing?

+1  A: 

With a "curl -D somefile" I can check that your cookie comes to the client exactly as specified. Can you check that, and confirm that the issue is with your browser and its settings rather than with the server side?

Alex Martelli
This was helpful too!
bentford
+5  A: 

The problem is you're using "expires:" with a colon. Needs to be "expires=" with an equals.

Bert Lamb
Perfect! That fixed the problem.
bentford
Those are the kind of problems you can stare at for hours and miss. I hate it when that happens. Glad to help!
Bert Lamb