Ruby-on-rails 在 rails 中清除会话变量的最佳方法是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3995816/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 23:27:10 来源:igfitidea点击:
What is the best way to clear a session variable in rails?
提问by Mohit Jain
session[:message] = nil
Is this is the best way to destroy a session variable.
这是销毁会话变量的最佳方法吗?
Note:I don't want to clear all the session variables like reset_sessiondoes.
注意:我不想像那样清除所有会话变量reset_session。
回答by Sigurd
session.delete(:message)
In general, session variable is SessionHashobject, which is inherited from hash.
一般来说,session变量是SessionHashobject,它是从hash继承而来的。

