Rails 6中不存在登录会话数据 [英] Login Session Data Not Persisting In Rails 6

查看:56
本文介绍了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆