-->

Session is not shared between requests using Snapl

2019-08-11 07:29发布

问题:

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.

回答1:

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.