#NEWLINE# def process_response( self , request , response ) : #NEWLINE# #INDENT# '\n        If request.session was modified, or if the configuration is to save the\n        session every time, save the changes and set a session cookie or delete\n        the session cookie if the session has been emptied.\n        ' #NEWLINE# try : #NEWLINE# #INDENT# accessed = request . session . accessed #NEWLINE# modified = request . session . modified #NEWLINE# empty = request . session . is_empty ( ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( settings . SESSION_COOKIE_NAME in request . COOKIES ) and empty ) : #NEWLINE# #INDENT# response . delete_cookie ( settings . SESSION_COOKIE_NAME , domain = settings . SESSION_COOKIE_DOMAIN ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if accessed : #NEWLINE# #INDENT# patch_vary_headers ( response , ( 'Cookie' , ) ) #NEWLINE# #UNINDENT# if ( ( modified or settings . SESSION_SAVE_EVERY_REQUEST ) and ( not empty ) ) : #NEWLINE# #INDENT# if request . session . get_expire_at_browser_close ( ) : #NEWLINE# #INDENT# max_age = None #NEWLINE# expires = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# max_age = request . session . get_expiry_age ( ) #NEWLINE# expires_time = ( time . time ( ) + max_age ) #NEWLINE# expires = cookie_date ( expires_time ) #NEWLINE# #UNINDENT# if ( response . status_code != 500 ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# request . session . save ( ) #NEWLINE# #UNINDENT# except UpdateError : #NEWLINE# #INDENT# return redirect ( request . path ) #NEWLINE# #UNINDENT# response . set_cookie ( settings . SESSION_COOKIE_NAME , request . session . session_key , max_age = max_age , expires = expires , domain = settings . SESSION_COOKIE_DOMAIN , path = settings . SESSION_COOKIE_PATH , secure = ( settings . SESSION_COOKIE_SECURE or None ) , httponly = ( settings . SESSION_COOKIE_HTTPONLY or None ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return response