Back to index

plone3  3.1.7
setAuthCookie.py
Go to the documentation of this file.
00001 ## Script (Python) "setAuthCookie"
00002 ##title=Set Authentication Cookie
00003 ##parameters=resp, cookie_name, cookie_value
00004 
00005 try:
00006     length = context.portal_properties.site_properties.auth_cookie_length
00007 except AttributeError:
00008     length = 0
00009 
00010 try:
00011     length = int(length)
00012 except ValueError:
00013     length = 0
00014 
00015 cookie_path = '/'
00016 if length:
00017     expires = (DateTime() + length).toZone('GMT').rfc822()
00018     resp.setCookie( cookie_name, cookie_value, path=cookie_path, expires=expires)
00019 else:
00020     resp.setCookie( cookie_name, cookie_value, path=cookie_path)