<s> from . base import BaseSession <EOL> import hashlib <EOL> from . utils import sign_payload , validate_payload , load_payload , dump_payload <EOL> from . globals import session_config <EOL> class SecureCookieSession ( BaseSession ) : <EOL> salt = '<STR_LIT>' <EOL> def __init__ ( self ) : <EOL> pass <EOL> def decode_session ( self , data ) : <EOL> validated , ret = validate_payload ( data ) <EOL> if validated : <EOL> return load_payload ( ret ) <EOL> return None <EOL> def encode_session ( self ) : <EOL> s = dump_payload ( data ) <EOL> return sign_payload ( s , session_config . get ( '<STR_LIT>' ) , salt ) <EOL> def open ( self , request ) : <EOL> value = request . get_cookie ( '<STR_LIT>' ) or '<STR_LIT>' <EOL> data = self . decode_session ( value ) or { } <EOL> self . update ( data ) <EOL> def save ( self , response ) : <EOL> data = self . encode_session ( dict ( self ) ) <EOL> response . set_cookie ( '<STR_LIT>' , data ) </s>
