我如何清除所有 Rails 会话? [英] How would I clear all rails sessions?

查看:49
本文介绍了我如何清除所有 Rails 会话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

if session[:firsttimestart].nil? 
else
  @firsttime = false
end

if @firsttime == true
  initglobals()
end
session[:firsttimestart]=false

问题是当我关闭服务器并返回应用程序时,会话 [:firsttimestart] 仍然是错误的.它以某种方式将此变量存储在我的系统中而没有到期日期,因此不调用 iniglobals().我尝试使用 rake tmp:clear 并且没有用.每次重新启动服务器时,如何清除系统中正在使用的所有会话?

The problem is when I turn off the server and come back to the application, the session[:firsttimestart] is still false. It somehow stores this variable in my system without an expiration date so the iniglobals() is not called. I tried to use rake tmp:clear and it didn't work. How can I clear all the sessions that am using in my system each time I restart my server?

推荐答案

如果您将会话存储在 db 中,则

If you are storing your sessions in a db then

rake db:sessions:clear

这篇关于我如何清除所有 Rails 会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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