def set_login_cookie(remove=False, remember_me=False):
 salt = randint(1, 1000)
 cherrypy.response.cookie['login_cookie'] = hashlib.sha1(((str(salt) + cherrypy.request.remote.ip) + COOKIE_SECRET)).hexdigest()
 cherrypy.response.cookie['login_cookie']['path'] = '/'
 cherrypy.response.cookie['login_salt'] = salt
 cherrypy.response.cookie['login_salt']['path'] = '/'
 if remember_me:
  cherrypy.response.cookie['login_cookie']['max-age'] = ((3600 * 24) * 14)
  cherrypy.response.cookie['login_salt']['max-age'] = ((3600 * 24) * 14)
 if remove:
  cherrypy.response.cookie['login_cookie']['expires'] = 0
  cherrypy.response.cookie['login_salt']['expires'] = 0
 else:
  notifier.send_notification(T('User logged in'), T('User logged in to the web interface'), 'new_login')

def set_login_cookie ( remove = False , remember_me = False ) : salt = randint ( 1 , 1000 ) cherrypy . response . cookie [ 'login_cookie' ] = hashlib . sha1 ( ( ( str ( salt ) + cherrypy . request . remote . ip ) + COOKIE_SECRET ) ) . hexdigest ( ) cherrypy . response . cookie [ 'login_cookie' ] [ 'path' ] = '/' cherrypy . response . cookie [ 'login_salt' ] = salt cherrypy . response . cookie [ 'login_salt' ] [ 'path' ] = '/' if remember_me : cherrypy . response . cookie [ 'login_cookie' ] [ 'max-age' ] = ( ( 3600 * 24 ) * 14 ) cherrypy . response . cookie [ 'login_salt' ] [ 'max-age' ] = ( ( 3600 * 24 ) * 14 ) if remove : cherrypy . response . cookie [ 'login_cookie' ] [ 'expires' ] = 0 cherrypy . response . cookie [ 'login_salt' ] [ 'expires' ] = 0 else : notifier . send_notification ( T ( 'User logged in' ) , T ( 'User logged in to the web interface' ) , 'new_login' )
we try to set a cookie as unique as possible to the current user .