In ruby on rails when doing session[:foo] = nil it leaves an entry named :foo in the session object. How can you get rid of that single entry from the session object?
In ruby on rails when doing session[:foo] = nil it leaves an entry named
Share
Actually there is a way to get delete a value from the session. Like RichH said the session variable is a CGI::Session instance. When enter something like
session[:foo]it is actually looking that symbol up in a@datainstance variable in the session object. That data variable is a hash.EDIT: There is a data instance variable in the CGI::Session class. If you go to the docs and look at the source code for the
[]=method you’ll see that there is a@datamember.So to delete
session[:foo]all you have to do is access that@datavariable from inside the sessionNow to delete it:
Once you do this the there should be no more foo in your session variable.