码迷,mamicode.com
首页 > 其他好文 > 详细

day36 cookies

时间:2017-07-08 16:13:09      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:logs   tar   back   second   type   settings   odi   opened   lan   

 

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=new Data();
    current_data.setSeconds(current_data.getSeconds()+6)
    $.cookie(‘k1‘,‘666‘,{expires:current_data})
// 这是保存6秒的
setcookie by day or sec

 

day36 cookies

标签:logs   tar   back   second   type   settings   odi   opened   lan   

原文地址:http://www.cnblogs.com/ezway/p/7137029.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!