web.py笔记 cookie

 

 

官方url http://webpy.org/cookbook/cookies.zh-cn

 

例子给的都很好

 

自己测试了下ssl连接的情况

只有ssl开启的时候,才可以置为true

否则,置为true也是取不到值得

 

以下是测试代码

 

import web
#from web.wsgiserver import CherryPyWSGIServer  
#from web.wsgiserver.ssl_builtin import BuiltinSSLAdapter  

#ssl_cert = "C:/Python27/Lib/test/ssl_cert.pem"  
#ssl_key = "C:/Python27/Lib/test/ssl_key.pem"  
  
  
#CherryPyWSGIServer.ssl_adapter = BuiltinSSLAdapter(ssl_cert,ssl_key,None)  
  
        
urls = (
    '/set', 'cookie1',
    '/get', 'cookie2',
)
app = web.application(urls, globals())


class cookie1:        
    def GET(self):
        
        web.setcookie('age', 28, 3600,None,True)
        return "Age set in your cookie"
    
class cookie2:        
    def GET(name):
        return web.cookies().get('age')  
    
        
    
if __name__ == "__main__":
    app.run()
 

你可能感兴趣的:(cookie)