Rails 6中不存在登录会话数据 [英] Login Session Data Not Persisting In Rails 6
花了一天时间尝试了其他建议之后,我终于发现我的浏览器实际上阻止了 session
持久存在./p>
我将浏览器更改为另一个浏览器,并且一切工作都像魔术一样.
I am implementing a user authentication system in Ruby on Rails following this tutorial Building a Simple Session Based Authentication using Ruby on Rails.
I think I did everything as explained in the article, but I could not get the user_id
to be persisted across page refresh after a successful login.
This is the log_in method
def log_in(user)
session[:user_id] = user.id
end
After I successfully logged in, I checked if the user id was saved in the session by printing out p session[:user_id]
it returns nil
After spending the day trying out various suggestions from others, I finally discovered that my browser was actually blocking the session
from persisting.
I changed my browser to another one and everything worked like magic.
这篇关于Rails 6中不存在登录会话数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!