What you want to achieve is possible, but you are thinking about it the wrong 
way. Do not call it a "global variable" --- that is not only the wrong word but 
refers to some other concept in Ruby which will not do what you think it will 
do.

Here's a great introduction to sessions & cookies with a detailed beginner 
explanation:

http://www.theodinproject.com/ruby-on-rails/sessions-cookies-and-authentication


when you're in a controller and you refer to session[:xyz] (see article above) 
that is not a local variable, but in fact a special construct by Rails to share 
information across web requests from the same user. It's already implemented 
for you -- use it, don't re-invent the wheel.

-Jason



On Sep 4, 2014, at 4:38 PM, António <[email protected]> wrote:

> The second controller checks the variable for knowing whether a user is 
> logged in. The idea is the @session variable to be a "global variable" of the 
> application, that is, used by several controllers. According to your answer, 
> it is not possible. Is that true?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/0F36F409-F0A1-48A3-A2C7-1A19AE6CB9F8%40datatravels.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to