1 2 3 4 5 6 7 8 9 10 11 12 | from django.conf import settings
import datetime
def set_cookie(response, key, value, expire=None):
if expire is None:
max_age = 365*24*60*60 #one year
else:
max_age = expire
expires = datetime.datetime.strftime(datetime.datetime.utcnow() + datetime.timedelta(seconds=max_age), "%a, %d-%b-%Y %H:%M:%S GMT")
response.set_cookie(key, value, max_age=max_age, expires=expires,
domain=settings.SESSION_COOKIE_DOMAIN, secure=settings.SESSION_COOKIE_SECURE or None)
|
More like this
- Effective content caching for mass-load site using redirect feature by nnseva 1 year, 11 months ago
- Validator for data by limodou 6 years, 3 months ago
- Amazon's CloudFront streaming signed urls by sayane 2 years, 9 months ago
- Extend generic view object_list to support paginate_by via cookies by kersurk 2 years, 5 months ago
- db_dump.py - for dumpping and loading data from database by limodou 6 years, 3 months ago
Comments
thank u so much :)
#