首页 > 代码库 > day36 cookies

day36 cookies

 

2017-7-8 15:45:30

技术分享
#! bin/usr/evn python
# -*- coding:utf-8 -*-
import tornado.web
import tornado.ioloop

class Indexhandler(tornado.web.RequestHandler):
    def get(self):
        self.set_cookie(k1,999)
        ret = self.cookies
        print(ret)
        self.render(index.html)

settings={
    "template_path":views

}
app=tornado.web.Application({
    (r/index,Indexhandler),
},**settings)

if __name__==__main__:
    app.listen(8888)
    tornado.ioloop.IOLoop.instance().start()
cookies

 

技术分享
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div style="color: #c03945;">cookies</div>

    <script>
        function setCookie(name,value,expires){
            var current_date = new Date();
            current_date.setSeconds(current_date.getSeconds() + 5);
            document.cookie = name + "= "+ value +";expires=" + current_date.toUTCString();
}
    </script>
</body>
</html>
index.html


 

技术分享
    $.cookie(‘k1‘,‘666‘,{expires:7}) 
//这是保存七天的
    var current_data=http://www.mamicode.com/new Data();>
setcookie by day or sec

 

day36 cookies