开发者

Sinatra sessions - why is what I put in different from what I get out?

开发者 https://www.devze.com 2023-03-15 03:54 出处:网络
I\'ve got the following declared: set :sessions, true and then in my controller, I have: session[$session_id] = user.session_id if save_successful

I've got the following declared:

set :sessions, true

and then in my controller, I have:

session[$session_id] = user.session_id if save_successful

which sets the session, and then on a trip back to the server, I have:

session_id = session[$session_id]

But when I compare what I initially store in the session, I have:

a878bbd83f217daabec1b160b00bdde6 (initally)
d1e6264b87ae240be5a25a7edbcc97e5688df133cada1c7ab50661ae2f752b48 (on trip back)
开发者_Python百科

Why is what I put into a session different from what I get out? and how do I make it the same???

Cheers,

Louis


I assume you meant for $session_id to be :session_id or 'session_id', variables that begin with dollar signs are global in Ruby (it is not the name of a key, but instead a globally visible reference to some object).

A good way to take a look would be to print session.inspect is the key what you think it should be?


I've posted a bug report on https://github.com/rack/rack/issues/197#issuecomment-1648851

If I use just :id instead of :session_id then it works :~)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号