在 rails 中清除会话变量的最佳方法是什么? [英] What is the best way to clear a session variable in rails?
本文介绍了在 rails 中清除会话变量的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
session[:message] = nil
这是销毁会话变量的最佳方式吗.
Is this is the best way to destroy a session variable.
注意:我不想像 reset_session
那样清除所有会话变量.
Note: I don't want to clear all the session variables like reset_session
does.
推荐答案
session.delete(:message)
一般来说,session变量是SessionHash
对象,它是从hash继承而来的.
In general, session variable is SessionHash
object, which is inherited from hash.
这篇关于在 rails 中清除会话变量的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文