Ticket #1406: turbogears_visit_cookie_timeout.patch
| File turbogears_visit_cookie_timeout.patch, 1.6 kB (added by j, 1 year ago) |
|---|
-
turbogears/visit/api.py
old new 3 3 import threading 4 4 from random import random 5 5 from datetime import timedelta, datetime 6 import time 6 7 7 8 import cherrypy 8 9 import pkg_resources … … 125 126 self.cookie_secure= get( "visit.cookie.secure", False ) 126 127 # By default, I don't specify the cookie domain. 127 128 self.cookie_domain= get( "visit.cookie.domain", None ) 129 self.cookie_max_age = int(get( "visit.timeout", "20")) * 60 128 130 assert self.cookie_domain!="localhost", \ 129 131 "localhost is not a valid value for visit.cookie.domain. Try None instead." 130 132 … … 194 196 cookies= cherrypy.response.simple_cookie 195 197 cookies[self.cookie_name]= visit_key 196 198 cookies[self.cookie_name]['path']= self.cookie_path 199 # We'd like to use the "max-age" param as 200 # http://www.faqs.org/rfcs/rfc2109.html indicates but IE doesn't 201 # save it to disk and the session is lost if people close 202 # the browser 203 # So we have to use the old "expires" ... sigh ... 204 #cookies[self.cookie_name]['max-age']= self.cookie_max_age 205 gmt_expiration_time = time.gmtime(time.time() + self.cookie_max_age) 206 cookies[self.cookie_name]['expires'] = time.strftime( 207 "%a, %d-%b-%Y %H:%M:%S GMT", gmt_expiration_time) 197 208 if self.cookie_secure: 198 209 cookies[self.cookie_name]['secure']= True 199 210 if self.cookie_domain: