# @session is getting reset?

**URL:** <https://www.ruby-forum.com/t/session-is-getting-reset/72095>\
**Category:** Rails\
**Created:** [October 14, 2006, 3:48am UTC](https://www.ruby-forum.com/t/session-is-getting-reset/72095 "2006-10-14T03:48:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![iceburgh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c4cdca/32.png) [@iceburgh](https://www.ruby-forum.com/u/iceburgh)\
**Post date:** [October 14, 2006, 3:48am UTC](https://www.ruby-forum.com/t/session-is-getting-reset/72095/1 "2006-10-14T03:48:53Z")

</div>

I got rid of the @ signs and went from strings to symbols,  
but things are still broken:

At the end of the login method (user\_controller.rb), I’m  
setting values into session, then redirecting, as:

```
  puts ">>>>> redirecting" # TRACE
  session[:user] = u.id
  session[:foozle] = 'bar' #{T}
  if (session[:foozle])
    puts ">>>>> login: foozle = '#{session[:foozle]}'"
  else
    puts ">>>>> login: foozle is undefined"
  end

  redirect_to :controller => 'main',
              :action => 'welcome'

```

This prints out

> > > > > redirecting  
> > > > > login: foozle = ‘bar’

Then, in get\_user (application.rb), I try to retrieve them:

```
if (session)
  puts ">>>>> session is defined in get_user"
  puts ">>>>> class = #{session.class}"
  if (session[:foozle])
    puts ">>>>> get_user: foozle = '#{session[:foozle]}'"
  else
    puts ">>>>> get_user: foozle is undefined"
  end
else
  puts ">>>>> session is undefined in get_user"
end

```

This prints out

> > > > > session is defined in get\_user  
> > > > > class = CGI::Session  
> > > > > get\_user: foozle is undefined  
> > > > > session[:user] is undefined

Oh yeah:

% rails --version  
Rails 1.1.6

## -r

[http://www.cfcl.com/rdm](http://www.cfcl.com/rdm) Rich M.  
[http://www.cfcl.com/rdm/resume](http://www.cfcl.com/rdm/resume) removed\_email\_address@domain.invalid  
[http://www.cfcl.com/rdm/weblog](http://www.cfcl.com/rdm/weblog) +1 650-873-7841

Technical editing and writing, programming, and web development

---

<div class="post-metadata">

**Author:** ![iceburgh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c4cdca/32.png) [@iceburgh](https://www.ruby-forum.com/u/iceburgh)\
**Post date:** [October 14, 2006, 7:08pm UTC](https://www.ruby-forum.com/t/session-is-getting-reset/72095/2 "2006-10-14T19:08:26Z")

</div>

Hi Rich,

Rich M. wrote:

> I got rid of the @ signs and went from strings to symbols,  
> but things are still broken:

I’ve been through it and honestly can’t see the problem either. Sorry I  
can’t be more help. I do hope you’ll post what you find here, though.  
Something on the wiki would be cool too.

Best regards,  
Bill

---

<div class="post-metadata">

**Author:** ![iceburgh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c4cdca/32.png) [@iceburgh](https://www.ruby-forum.com/u/iceburgh)\
**Post date:** [October 15, 2006, 2:19am UTC](https://www.ruby-forum.com/t/session-is-getting-reset/72095/3 "2006-10-15T02:19:15Z")

</div>

On Fri, Oct 13, 2006, Rich M. wrote:

> I got rid of the @ signs and went from strings to symbols,  
> but things are still broken:

I just copied/pasted your code into a test application, and it  
WORKSFORME. Either your environment is screwed up, or some code that  
you’re not showing us is breaking it.

Try to copy exactly what you sent out into a new application and give it  
a go. You’ll have to change u.id to something else… if that works  
fine, then your session is getting munged somewhere else in your app.

Ben

---

<div class="post-metadata">

**Author:** ![iceburgh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c4cdca/32.png) [@iceburgh](https://www.ruby-forum.com/u/iceburgh)\
**Post date:** [October 15, 2006, 4:35am UTC](https://www.ruby-forum.com/t/session-is-getting-reset/72095/4 "2006-10-15T04:35:24Z")

</div>

(coming into this conversation late…)

possible write error(permissions) in your session folder?

J
