MCPcopy Create free account
hub / github.com/pyload/pyload / CookieSession

Class CookieSession

module/lib/beaker/session.py:325–521  ·  view source on GitHub ↗

Pure cookie-based session Options recognized when using cookie-based sessions are slightly more restricted than general sessions. ``key`` The name the cookie should be set to. ``timeout`` How long session data is considered valid. This is used regar

Source from the content-addressed store, hash-verified

323 self.namespace.release_write_lock()
324
325class CookieSession(Session):
326 """Pure cookie-based session
327
328 Options recognized when using cookie-based sessions are slightly
329 more restricted than general sessions.
330
331 ``key``
332 The name the cookie should be set to.
333 ``timeout``
334 How long session data is considered valid. This is used
335 regardless of the cookie being present or not to determine
336 whether session data is still valid.
337 ``encrypt_key``
338 The key to use for the session encryption, if not provided the
339 session will not be encrypted.
340 ``validate_key``
341 The key used to sign the encrypted session
342 ``cookie_domain``
343 Domain to use for the cookie.
344 ``secure``
345 Whether or not the cookie should only be sent over SSL.
346
347 """
348 def __init__(self, request, key='beaker.session.id', timeout=None,
349 cookie_expires=True, cookie_domain=None, encrypt_key=None,
350 validate_key=None, secure=False, **kwargs):
351
352 if not crypto.has_aes and encrypt_key:
353 raise InvalidCryptoBackendError("No AES library is installed, can't generate "
354 "encrypted cookie-only Session.")
355
356 self.request = request
357 self.key = key
358 self.timeout = timeout
359 self.cookie_expires = cookie_expires
360 self.encrypt_key = encrypt_key
361 self.validate_key = validate_key
362 self.request['set_cookie'] = False
363 self.secure = secure
364 self._domain = cookie_domain
365 self._path = '/'
366
367 try:
368 cookieheader = request['cookie']
369 except KeyError:
370 cookieheader = ''
371
372 if validate_key is None:
373 raise BeakerException("No validate_key specified for Cookie only "
374 "Session.")
375
376 try:
377 self.cookie = SignedCookie(validate_key, input=cookieheader)
378 except Cookie.CookieError:
379 self.cookie = SignedCookie(validate_key, input=None)
380
381 self['_id'] = self._make_id()
382 self.is_new = True

Callers 1

_sessionMethod · 0.85

Calls 1

propertyClass · 0.85

Tested by

no test coverage detected