# Cookies/Session Management

**URL:** <https://www.ruby-forum.com/t/cookies-session-management/122975>\
**Category:** Rails\
**Created:** [December 13, 2007, 5:06am UTC](https://www.ruby-forum.com/t/cookies-session-management/122975 "2007-12-13T05:06:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![corywilkerson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/aca169/32.png) [@corywilkerson](https://www.ruby-forum.com/u/corywilkerson)\
**Post date:** [December 13, 2007, 5:06am UTC](https://www.ruby-forum.com/t/cookies-session-management/122975/1 "2007-12-13T05:06:54Z")

</div>

All,

I tried to take this to my host but they’ve deferred to me which means  
I’m deferring to the community.

I’ve currently got an issue where my application is giving a user two  
distinct sessions/cookies - not a good thing. The first session is  
allocated when a user hits [www.foo.com](http://www.foo.com) for the first time, however, if  
the user then hits [foo.com](http://foo.com) (sans the www), my application issues this  
user a new session.

This sounds like a hosting issue but they’ve indicated it’s in the app.  
Any pointers? Suggestions on where to start digging? Seems like the  
answer is to tail rails to issue cookies for \*.foo.com and not per  
subdomain ([www.foo.com](http://www.foo.com))…

TIA,  
Cory

---

<div class="post-metadata">

**Author:** ![corywilkerson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/aca169/32.png) [@corywilkerson](https://www.ruby-forum.com/u/corywilkerson)\
**Post date:** [December 13, 2007, 5:13am UTC](https://www.ruby-forum.com/t/cookies-session-management/122975/2 "2007-12-13T05:13:00Z")

</div>

Well, you can work around this issue by making your website work on  
[www.foo.com](http://www.foo.com) and all other subdomains to redirect to your website.

If you tell rails to use \*.foo.com for your cookie (dunno how to do  
that), you are going to have problems if you decide to use a subdomain  
for something else, like a forum, that usually sets a cookie on its  
own.

As it is, this is indeed an issue with you/app and not the web host.

On Dec 12, 8:06 pm, Cory W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![corywilkerson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/aca169/32.png) [@corywilkerson](https://www.ruby-forum.com/u/corywilkerson)\
**Post date:** [December 13, 2007, 5:28am UTC](https://www.ruby-forum.com/t/cookies-session-management/122975/3 "2007-12-13T05:28:22Z")

</div>

This should do the trick:  
[http://wiki.rubyonrails.org/rails/pages/HowtoChangeSessionOptions](http://wiki.rubyonrails.org/rails/pages/HowtoChangeSessionOptions)
