Hi Let''s say we set session[:foo] = ''bar''. Now we want to remove the :foo key completely. How do you do that? Appearantly, session is a CGI::Session [1] instance, so it doesn''t have #delete like Hash. I tried: session[:foo] = nil But then debug(session) shows an empty :foo key. I''d like to remove that key, as my session is already pretty crowded. Is it possible? -- -Alder [1] http://ruby-doc.org/core/classes/CGI/Session.html
On Thursday, May 18, 2006, at 11:56 AM, Alder Green wrote:>Hi > >Let''s say we set session[:foo] = ''bar''. Now we want to remove the :foo >key completely. How do you do that? > >Appearantly, session is a CGI::Session [1] instance, so it doesn''t >have #delete like Hash. I tried: > >session[:foo] = nil > >But then debug(session) shows an empty :foo key. I''d like to remove >that key, as my session is already pretty crowded. Is it possible? > >-- >-Alder > >[1] http://ruby-doc.org/core/classes/CGI/Session.html >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/railsWill session.delete["foo"] work? -- Posted with http://DevLists.com. Sign up and save your mailbox.
see http://wiki.rubyonrails.org/rails/pages/HowtoWorkWithSessions for your answer. On 18 May 2006 14:44:35 -0000, Richard Williams < devlists-rubyonrails@devlists.com> wrote:> > > On Thursday, May 18, 2006, at 11:56 AM, Alder Green wrote: > >Hi > > > >Let''s say we set session[:foo] = ''bar''. Now we want to remove the :foo > >key completely. How do you do that? > > > >Appearantly, session is a CGI::Session [1] instance, so it doesn''t > >have #delete like Hash. I tried: > > > >session[:foo] = nil > > > >But then debug(session) shows an empty :foo key. I''d like to remove > >that key, as my session is already pretty crowded. Is it possible? > > > >-- > >-Alder > > > >[1] http://ruby-doc.org/core/classes/CGI/Session.html > >_______________________________________________ > >Rails mailing list > >Rails@lists.rubyonrails.org > >http://lists.rubyonrails.org/mailman/listinfo/rails > > > Will session.delete["foo"] work? > > -- > Posted with http://DevLists.com. Sign up and save your mailbox. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060518/8879ab66/attachment-0001.html
On 18 May 2006 14:44:35 -0000, Richard Williams <devlists-rubyonrails@devlists.com> wrote:> > On Thursday, May 18, 2006, at 11:56 AM, Alder Green wrote: > >Hi > > > >Let''s say we set session[:foo] = ''bar''. Now we want to remove the :foo > >key completely. How do you do that? > > > >Appearantly, session is a CGI::Session [1] instance, so it doesn''t > >have #delete like Hash. I tried: > > > >session[:foo] = nil > > > >But then debug(session) shows an empty :foo key. I''d like to remove > >that key, as my session is already pretty crowded. Is it possible? > > > >-- > >-Alder > > > >[1] http://ruby-doc.org/core/classes/CGI/Session.html > >_______________________________________________ > >Rails mailing list > >Rails@lists.rubyonrails.org > >http://lists.rubyonrails.org/mailman/listinfo/rails > > > Will session.delete["foo"] work?No, since the object returned by #session isn''t a Hash - it''s a Hash-like instance of CGI::Session. So it doesn''t have the various Hash intance methods. It does have a #hash method btw, but it does something entirely different ("Delete the session from storage. Also closes the storage.") -- -Alder
On 5/18/06, Chris Hall <christopher.k.hall@gmail.com> wrote:> > see > http://wiki.rubyonrails.org/rails/pages/HowtoWorkWithSessions > for your answer." Completely removing a previously-set key/value pair: [not possible] " Ok, guess it''s better than no answer :) Thanks. -- -Alder
Reasonably Related Threads
- Any good alternative to single-table-inheritance?
- create separate plots by factors
- Non-customizable parts in the routes hierarchy-chain.
- Running Rails tasks by schedule, instead of an HTTP request.
- How to SELECT from multiple talbes with AR#find and associations?