Ejemplo n.º 1
0
 def setCookie(self, key, value, maxAge=None, Expires=None):
     cookie = Cookie(key, value)
     if maxAge:
         cookie.setMaxAge(maxAge)
     if Expires:
         cookie.setExpires(Expires)
     self.response().addCookie(cookie)
Ejemplo n.º 2
0
 def setCookie(self, key, value, maxAge=None, Expires=None):
     cookie = Cookie(key, value)
     if maxAge:
         cookie.setMaxAge(maxAge)
     if Expires:
         cookie.setExpires(Expires)
     self.response().addCookie(cookie)
Ejemplo n.º 3
0
	def recordSession(self):
		""" Invoked by commit() to record the session id in the response (if a session exists). This implementation sets a cookie for that purpose. For people who don't like sweets, a future version could check a setting and instead of using cookies, could parse the HTML and update all the relevant URLs to include the session id (which implies a big performance hit). Or we could require site developers to always pass their URLs through a function which adds the session id (which implies pain). Personally, I'd rather just use cookies. You can experiment with different techniques by subclassing Session and overriding this method. Just make sure Application knows which "session" class to use. """
		sess = self._transaction._session
		if debug: prefix = '>> recordSession:'
		if sess:
			cookie = Cookie('_SID_', sess.identifier())
			cookie.setPath('/')
			if sess.isExpired() or sess.timeout() == 0:
				# Invalid -- tell client to forget the cookie.
				cookie.setMaxAge(0)
				cookie.setExpires(-365*24*60*60)
			self.addCookie(cookie)
			if debug: print prefix, 'setting sid =', sess.identifier()
		else:
			if debug: print prefix, 'did not set sid'