# Ruby Sessions - getting created for every request from IE

**URL:** <https://www.ruby-forum.com/t/ruby-sessions-getting-created-for-every-request-from-ie/145744>\
**Category:** Rails\
**Created:** [August 13, 2008, 4:02pm UTC](https://www.ruby-forum.com/t/ruby-sessions-getting-created-for-every-request-from-ie/145744 "2008-08-13T16:02:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sgudibanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@sgudibanda](https://www.ruby-forum.com/u/sgudibanda)\
**Post date:** [August 13, 2008, 4:02pm UTC](https://www.ruby-forum.com/t/ruby-sessions-getting-created-for-every-request-from-ie/145744/1 "2008-08-13T16:02:32Z")

</div>

Hi,

I am seeing this weird bug. I create a session for each new user, and  
keep updating the same session. If he logs in, i update his user\_id into  
the session, so that i can keep track if he is logged in or not,and such  
things.

But sometimes in IE, no matter how many times a user enters his  
credentials, it wouldn’t let him in. When i tried to debug,

I saw this process: It actually updates the session after  
authenticating. But when he is redirected to his profile page, a new  
session is getting created and user\_id is NULL for that. So he is forced  
to login page again.

This happens only in IE7 and only sometimes. But when it happens, it  
doesnt let the user in.

Has anyone faced similar situation? Please suggest.

Regards,  
SG

---

<div class="post-metadata">

**Author:** ![sgudibanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@sgudibanda](https://www.ruby-forum.com/u/sgudibanda)\
**Post date:** [August 20, 2008, 6:05am UTC](https://www.ruby-forum.com/t/ruby-sessions-getting-created-for-every-request-from-ie/145744/2 "2008-08-20T06:05:48Z")

</div>

Sandeep G. wrote:

> Hi,
> 
> I am seeing this weird bug. I create a session for each new user, and  
> keep updating the same session. If he logs in, i update his user\_id into  
> the session, so that i can keep track if he is logged in or not,and such  
> things.
> 
> But sometimes in IE, no matter how many times a user enters his  
> credentials, it wouldn’t let him in. When i tried to debug,
> 
> I saw this process: It actually updates the session after  
> authenticating. But when he is redirected to his profile page, a new  
> session is getting created and user\_id is NULL for that. So he is forced  
> to login page again.
> 
> This happens only in IE7 and only sometimes. But when it happens, it  
> doesnt let the user in.
> 
> Has anyone faced similar situation? Please suggest.
> 
> Regards,  
> SG

I’m seeing the same thing. Except it sometimes happens on IE 6 for me  
also. Are you using AuthenticatedSystem?

- jason

---

<div class="post-metadata">

**Author:** ![sgudibanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@sgudibanda](https://www.ruby-forum.com/u/sgudibanda)\
**Post date:** [August 20, 2008, 6:11am UTC](https://www.ruby-forum.com/t/ruby-sessions-getting-created-for-every-request-from-ie/145744/3 "2008-08-20T06:11:00Z")

</div>

Jason L. wrote:

> I’m seeing the same thing. Except it sometimes happens on IE 6 for me  
> also. Are you using AuthenticatedSystem?
> 
> - jason

And what makes it worse for me is that it only happens on SOME machines.  
I have various vmware instances setup - Vista w/IE7, XP w/IE7, XP w/IE6

- and I cannot duplicate it on any of them - it always works.

However, my co-worker on random other machines have this problem (these  
are machines and friends and relatives houses).

For me, my sessions controller authenticates fine, but then when I  
redirect to my dashboard controller, I can see my ‘before\_filter  
:login\_required’ hook the request and redirect it to the login page.

We’re also using SSL for our site, so I don’t know if that makes any  
difference. I’m thinking about moving off cookie session store and maybe  
active record or local file system to see if this makes a difference.

---

<div class="post-metadata">

**Author:** ![sgudibanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@sgudibanda](https://www.ruby-forum.com/u/sgudibanda)\
**Post date:** [August 20, 2008, 7:29am UTC](https://www.ruby-forum.com/t/ruby-sessions-getting-created-for-every-request-from-ie/145744/4 "2008-08-20T07:29:18Z")

</div>

I use act\_as\_authenticated…But no luck with cracking this bug though.☹

---

<div class="post-metadata">

**Author:** ![sgudibanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@sgudibanda](https://www.ruby-forum.com/u/sgudibanda)\
**Post date:** [August 21, 2008, 10:24pm UTC](https://www.ruby-forum.com/t/ruby-sessions-getting-created-for-every-request-from-ie/145744/5 "2008-08-21T22:24:28Z")

</div>

Sandeep G. wrote:

> I use act\_as\_authenticated…But no luck with cracking this bug though.☹

So I’ve been monitoring our app and so far, some of the IE machines we  
were having problems with are working - _so far_. We’re still working on  
testing the other ones. Plus, I don’t know if it matters, but we’re  
using SSL with all the auth.

What I did was switch over to active record session store. In doing this  
I had to make sure the protect\_from\_forgery with secret was uncommented  
in the application.rb controller.  
Also, I had a few forms that I generated by hand (for some optimized js  
stuff) and I had to go back to them to make sure that they included the  
auth tag

After that, things seemed to be ok. This is the first time I’ve used the  
active record store and it is noticeably slower (maybe just to me), but  
I can live with it as long as things work. I’m curious how other sites  
are not experiencing this same issue…?

Maybe this might help?
