# Help with session variables in firefox

**URL:** <https://www.ruby-forum.com/t/help-with-session-variables-in-firefox/138028>\
**Category:** Rails\
**Created:** [May 19, 2008, 5:06pm UTC](https://www.ruby-forum.com/t/help-with-session-variables-in-firefox/138028 "2008-05-19T17:06:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [May 19, 2008, 5:06pm UTC](https://www.ruby-forum.com/t/help-with-session-variables-in-firefox/138028/1 "2008-05-19T17:06:13Z")

</div>

I have an action “new” which has a before\_filter to reset the  
session[:count] variable to 1. I then render this variable in the view  
and it is as expected.

in the view their is an link\_to\_remote which calls the method  
extra\_image. This function should add 1 to the session variable as  
well as rendering some extra html within the page.

However in firefox the session[:count] variable will not be reset to

1. It keeps adding 1 to its existing value. The only way I can get  
every thing to work as it should is to clear the cache in firefox.

Just to get a little stranger it works fine on my local machine with  
firefox but not on the hosting server. Both boxes are running the same  
version of mongrel and shockingly to say it works fine in IE (OMG)

I have included the methods from my controller below and if anyone  
would like to see the problem in action go to  
[http://tony.swsnow.net/admin/photos/new](http://tony.swsnow.net/admin/photos/new)  
It will work the first time as the session[:count] variable will start  
off at . Just reload the page and the problem will become clear.

class Admin::PhotosController \< ApplicationController  
before\_filter :reset\_count, :only =\> [:new] #resets  
session[:count] to 1 before action “new”

def reset\_count  
session[:count] = 1  
return session[:count]  
end

def new  
@photo = Photo.new  
@categories = Category.find(:all)  
@selected = [1]  
end

def extra\_image  
session[:count] += 1  
render :update do |page|  
page.insert\_html :bottom, :image\_upload, :partial =\>  
“upload\_form”  
page[:title].replace\_html “Add a new photo #{session[:count]}”  
page[:image\_name].hide  
end  
end

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [May 20, 2008, 6:16am UTC](https://www.ruby-forum.com/t/help-with-session-variables-in-firefox/138028/2 "2008-05-20T06:16:47Z")

</div>

It’s hard to see from your code, but it looks to me like you’re  
continually  
going to extra\_image in firefox (hence the always adding 1) and in IE  
you’re  
going to the new action (hence always resetting to 1)

–  
Appreciated my help?  
Recommend me on Working With Rails  
[http://workingwithrails.com/person/11030-ryan-bigg](http://workingwithrails.com/person/11030-ryan-bigg)
