# Dynamically setting the session domain?

**URL:** <https://www.ruby-forum.com/t/dynamically-setting-the-session-domain/97993>\
**Category:** Rails\
**Created:** [July 11, 2006, 10:43pm UTC](https://www.ruby-forum.com/t/dynamically-setting-the-session-domain/97993 "2006-07-11T22:43:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zack\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/eb9ed0/32.png) [@Zack\_C](https://www.ruby-forum.com/u/Zack_C)\
**Post date:** [July 11, 2006, 10:43pm UTC](https://www.ruby-forum.com/t/dynamically-setting-the-session-domain/97993/1 "2006-07-11T22:43:18Z")

</div>

Does anyone know a way to dynamically change the session\_domain option  
of ActionController::CgiRequest? I want to have a login section on an  
index page ([www.example.com](http://www.example.com)) that takes a subdomain, username,  
password, authenticates, then redirects to  
http://#{subdomain}.mysite.com.

I need to set the session\_domain option (to the subdomain) dynamically  
so the cookie can be read when the user arrives after the redirect. I  
know I could do  
ActionController::CgiRequest::DEFAULT\_SESSION\_OPTIONS.update(  
:session\_domain =\> ‘[example.com](http://example.com)’) if I wanted to share sessions across  
domains, but I do not want to do this as I want to allow users to be  
logged on to multiple subdomains at the same time.

Any ideas?

Thanks,  
Zack

---

<div class="post-metadata">

**Author:** ![Zack\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/eb9ed0/32.png) [@Zack\_C](https://www.ruby-forum.com/u/Zack_C)\
**Post date:** [July 12, 2006, 4:56pm UTC](https://www.ruby-forum.com/t/dynamically-setting-the-session-domain/97993/2 "2006-07-12T16:56:42Z")

</div>

I just realized that 37Signal’s Backpack does exactly what I described  
below. Any ideas on how this is done?

Thanks,  
Zack
