开发者

Rails - Session not saving

开发者 https://www.devze.com 2023-03-03 05:18 出处:网络
I have a session that is set but it does not appear to carry over to other pages. I\'m on Rails 2.3.5 开发者_开发知识库and Ruby 1.8.7. Has anyone else experienced this issue? I\'ve had this issue in R

I have a session that is set but it does not appear to carry over to other pages. I'm on Rails 2.3.5 开发者_开发知识库and Ruby 1.8.7. Has anyone else experienced this issue?


I've had this issue in Rails 3.1 when CSRF verification fails. This can happen if you use a tag manually rather than generate it via one of the built-in methods provided by Rails.

Search your log file for "csrf" (case insensitive search). If you see a log entry showing a csrf failure, it's likely Rails is resetting your session.


You may be losing your session between requests which can happen if it's not established properly in the first place. If you examine your cookies you may see the session identifier changing, being re-assigned, because of a validation failure.

It's also possible that it's being assigned to a domain that the browser subsequently rejects. This happens if an application is configured to use a specific domain, and is then re-hosted under a different one, even localhost.


You might have not used csrf meta tag in your layout. Try removing ' protect from forgery ' in application_controller.rb in controllers folder. Then try running the app again, if it works then you didn't add tags to your layout.

0

精彩评论

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