Can anyone put light on me and tell me how to intercept session start event? I want to initialize some of session constans... I thought about application controler filter but haven''t found the list of possible filters :( Big thanks in advance
Krzysztof Chodak wrote:>Can anyone put light on me and tell me how to intercept session start event? I >want to initialize some of session constans... > >I don''t know exactly what you mean by "session constants" Do you mean constants stored in a session or constants that define session behaviour (eg. place where session files are stored, session expiry etc)>I thought about application controler filter but haven''t found the list of >possible filters :( >Big thanks in advance > > >You can create your own filter, it is very easy just put before_filter :filter_name at the beginning of application_controller.rb or any other controller Drop me a PM if you want to talk about Rails in Polish :) I''d be happy to know someone here. -- Best Karol Hosiawa
for your application controller: before_filter :initialize_session def initialize_session session[:var1] ||= "variable 1" session[:var2] ||= "variable 2" session[:var3] ||= "variable 3" end On 6/23/05, Krzysztof Chodak <k.chodak-9g2oKKwXsvKzyIjkdXusMg@public.gmane.org> wrote:> Can anyone put light on me and tell me how to intercept session start event? I > want to initialize some of session constans... > I thought about application controler filter but haven''t found the list of > possible filters :( > Big thanks in advance > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Tobi http://www.snowdevil.ca - Snowboards that don''t suck http://typo.leetsoft.com - Open source weblog engine http://blog.leetsoft.com - Technical weblog
Tobias Luetke <tobias.luetke@...> writes:> > for your application controller: > > before_filter :initialize_session > > def initialize_session > session[:var1] ||= "variable 1" > session[:var2] ||= "variable 2" > session[:var3] ||= "variable 3" > end >but it will happen on every page hit not once on session start... simply: a search for example for ASP Session_OnStart() equivalent
On 6/24/05, Krzysztof Chodak <k.chodak-9g2oKKwXsvKzyIjkdXusMg@public.gmane.org> wrote:> > > > def initialize_session > > session[:var1] ||= "variable 1" > > session[:var2] ||= "variable 2" > > session[:var3] ||= "variable 3" > > end > > > > but it will happen on every page hit not once on session start... > simply: a search for example for ASP Session_OnStart() equivalentNotice the use of the ||= operator which won''t set it if it''s already defined... j -- http://johansorensen.com http://theexciter.com