SFEley / sinatra-flash

TODO: one-line summary of your gem
Other
154 stars 24 forks source link

Be careful when using the 'shotgun' gem #7

Open alssndro opened 10 years ago

alssndro commented 10 years ago

For anyone else who made this oversight while using Shotgun, be warned that sinatra-flash appears as though it isn't working, but really it is.

I'm assuming this is because Shotgun reloads the entire Sinatra app on each request, so sessions weren't working as they would normally.

So don't use shotgun while testing, use webbrick/unicorn/any other server.

Hopefully this saves someone else a lot of time!

P.S Maybe worth mentioning in the README somewhere?

rchampourlier commented 10 years ago

"Hopefully this saves someone else a lot of time!"

Yes, saved me!

fetmar commented 10 years ago

You saved me whatever I was about to spend after an evening and a morning of wondering what on Earth was happening to my brain. Thank you!

josemotanet commented 9 years ago

:laughing: I can't believe I felt into this. Thanks for letting the issue open so dumb guys like me can appreciate your remark.

odigity commented 8 years ago

Does anyone know why this is happening? It's not obvious to me that merely reloading the app on each request should cause this problem. The flash content is stored in a session cookie, which will be sent back to the app on the next request. The fact that the app was reloaded in between requests should not break anything.

josemotanet commented 8 years ago

I think that, because shotgun reloads the entire app (does it spawn a new one? I'm not sure), the cookies on the server side are lost since it's the one that issues those cookies in the first place; at least, regarding flash messaging. Only when the HTTP response is returned, the cookie is stored. Because the process is interrupted in each request, redirection and message passing fail.

gnfisher commented 8 years ago

Thank you for this. I was going a little crazy wondering why the flash hash was empty in my view!

inem commented 6 years ago

Here's workaround that worked for me. Just add set :session_secret, "something" to your app.