用lua 对cookie的控制

时间:2015-06-07 11:14:13   收藏:0   阅读:4552

header_filter_by_lua ‘

        t = {}

        if ngx.var.http_cookie then

            s = ngx.var.http_cookie

            for k, v in string.gmatch(s, "(%w+)=([%w%/%.=_-]+)") do

                t[k] = v

            end

        end

                                                      

        p = ngx.req.get_uri_args()

                                                      

        if not t.uid and p.uid then

            expires = ngx.cookie_time(4523969511)

            ngx.header["Set-Cookie"] = {"uid=" .. p.uid .."; expires=" .. expires .. ";

        end

                                                      

‘;


原文:http://my.oschina.net/epiclight/blog/425898

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!