问题描述
这是有道理的。但是,这个问题有哪些首选的解决方法?在解决方案中,我建议使用,但看着它,Sinatra会话 仍然是Rack cookie会话。
展望未来,我:
$ b
$ b set:session_secret,'super secret' $ b
因此,似乎每个Heroku dyno都生成不同的密钥,因此不能读取其他每个会话cookie,并且您需要指定一个密钥,以便每个dyno使用相同的密钥。
与其向您的源代码添加密钥,您可能更好地设置:
$ heroku config:add SESSION_KEY = a_longish_secret_key
然后在你的sinatra应用程序中:
enable: session
set:session_secret,ENV ['SESSION_KEY']
Which makes sense. But what are some preferred work arounds for this issue?
解决方案In my comment, I suggested using rack cookie based sessions, but looking into it, the Sinatra sessions are Rack cookie sessions anyway.
Looking further, I found this in the Sinatra docs:
So it seems each Heroku dyno is generating a different key, and so can't read each others session cookies, and you need to specify a key so each dyno uses the same one.
Rather than add a secret key to your source code, you're probably better setting an environment variable:
$ heroku config:add SESSION_KEY=a_longish_secret_keyThen in your sinatra app:
enable :sessions set :session_secret, ENV['SESSION_KEY']
这篇关于在Heroku的Sinatra应用程序中,会话不是跨Dynos共享的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!