views:

31

answers:

1
session[:message]=nil

Is this is the best way to destroy a session variable.

Note: *I dont want to clear all the session variables like reset_session do.*

+2  A: 

session.delete(:message) In general, session variable is SessionHash object, which is inherited from hash.

c0r0ner
This is the correct way to do it. session[:message] = nil will leave the :message key in the session hash, this will destroy the key and value, as if your session never had any value assigned to that key.
Brett Bender