# Having problems with global variable

**URL:** <https://www.ruby-forum.com/t/having-problems-with-global-variable/110568>\
**Category:** Rails\
**Created:** [July 27, 2007, 4:40pm UTC](https://www.ruby-forum.com/t/having-problems-with-global-variable/110568 "2007-07-27T16:40:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bloc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e8c25b/32.png) [@bloc](https://www.ruby-forum.com/u/bloc)\
**Post date:** [July 27, 2007, 4:40pm UTC](https://www.ruby-forum.com/t/having-problems-with-global-variable/110568/1 "2007-07-27T16:40:27Z")

</div>

Hi all,  
I am working on a webapp where a user can login, the login process binds  
with LDAP to see if the user is in LDAP. If its successful, I store the  
params[:login] to a global variable so I can use that in the rest of the  
application.

The problem is:  
When i open up two browser windows and login in with two different  
users, the variable is set to the user information used in the second  
login. So when I switch back to the first browser window and refresh, I  
see the second user information. Hopefully this makes sense, if not  
please let me know. I will rephrase it.

Thanks,  
Dev

---

<div class="post-metadata">

**Author:** ![bloc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e8c25b/32.png) [@bloc](https://www.ruby-forum.com/u/bloc)\
**Post date:** [July 29, 2007, 2:33pm UTC](https://www.ruby-forum.com/t/having-problems-with-global-variable/110568/2 "2007-07-29T14:33:21Z")

</div>

That behaviour is to be expected if you are using a global variable…  
What you probably want to be doing is storing it in a session variable  
instead.
