def check_session_cookie(response):
 for cookie in request.cookies:
  if ((cookie == u'ckan') and (not getattr(g, u'user', None))):
   is_valid_cookie_data = False
   for (key, value) in session.items():
    if ((not key.startswith(u'_')) and value):
     is_valid_cookie_data = True
     break
   if (not is_valid_cookie_data):
    if session.id:
     log.debug(u'No valid session data - deleting session')
     log.debug(u'Session: %r', session.items())
     session.delete()
    else:
     log.debug(u'No session id - deleting session cookie')
     response.delete_cookie(cookie)
  elif ((cookie == u'auth_tkt') and (not session.id)):
   response.delete_cookie(cookie)
 return response

def check_session_cookie ( response ) : for cookie in request . cookies : if ( ( cookie == u'ckan' ) and ( not getattr ( g , u'user' , None ) ) ) : is_valid_cookie_data = False for ( key , value ) in session . items ( ) : if ( ( not key . startswith ( u'_' ) ) and value ) : is_valid_cookie_data = True break if ( not is_valid_cookie_data ) : if session . id : log . debug ( u'No valid session data - deleting session' ) log . debug ( u'Session: %r' , session . items ( ) ) session . delete ( ) else : log . debug ( u'No session id - deleting session cookie' ) response . delete_cookie ( cookie ) elif ( ( cookie == u'auth_tkt' ) and ( not session . id ) ) : response . delete_cookie ( cookie ) return response
the cookies for auth and session are separate .