在rails中清除会话变量的最佳方法是什么?


Answers:


237
session.delete(:message)

通常,会话变量是SessionHash对象,它是从哈希继承的。


16
这是正确的方法。session [:message] = nil会将:message密钥保留在会话哈希中,这将破坏该密钥和值,就像您的会话从未为该密钥分配任何值一样。
Brett Bender
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.