使用Snaplet.Session在请求之间不共享会话 [英] Session is not shared between requests using Snaplet.Session

查看:78
本文介绍了使用Snaplet.Session在请求之间不共享会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Snaplet和会话的简单示例此处

$ curl http://localhost:8000/sessioin -d "key=k&value=v"
k
getter

$ curl http://localhost:8000/sessioin

getter

我无法在第二个请求中获得会话.

解决方案

根据您对with的定义,您可能在设置会话值后忘记提交会话.

此外,您正在使用curl来测试该系统. curl默认情况下不保留cookie,这就是您的会话cookie丢失的原因.尝试使用此功能(可在我的计算机上使用):

curl -c cookies.txt http://localhost:8000/session -d "key=k&value=v"
curl -b cookies.txt http://localhost:8000/session

另请参阅您先前的问题的修订答案./p>

A simple example of Snaplet and Session here

$ curl http://localhost:8000/sessioin -d "key=k&value=v"
k
getter

$ curl http://localhost:8000/sessioin

getter

I cannot get session in the 2nd request.

解决方案

Depending on your definition of with, you probably forgot to commit your session after you set values in it.

Also, you're using curl to test this system. curl doesn't preserve cookies by default, which is why your session cookie is lost. Try using this (works on my machine):

curl -c cookies.txt http://localhost:8000/session -d "key=k&value=v"
curl -b cookies.txt http://localhost:8000/session

See also the revised answer to your previous question.

这篇关于使用Snaplet.Session在请求之间不共享会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆