# Why can't I changed the \_session\_id cookie?

**URL:** <https://www.ruby-forum.com/t/why-cant-i-changed-the-session-id-cookie/52437>\
**Category:** Rails\
**Created:** [January 14, 2006, 1:03am UTC](https://www.ruby-forum.com/t/why-cant-i-changed-the-session-id-cookie/52437 "2006-01-14T01:03:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![generik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/4da419/32.png) [@generik](https://www.ruby-forum.com/u/generik)\
**Post date:** [January 14, 2006, 1:03am UTC](https://www.ruby-forum.com/t/why-cant-i-changed-the-session-id-cookie/52437/1 "2006-01-14T01:03:17Z")

</div>

Hi,

I noticed that there is a cookie set by my rails scaffold that contains  
a 32 character hash code in it, but when I tried to change its value  
using Cookies[:\_session\_id], nothing happened, it stays the same!

How am I supposed to change the session\_id?

Thanks.

---

<div class="post-metadata">

**Author:** ![generik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/4da419/32.png) [@generik](https://www.ruby-forum.com/u/generik)\
**Post date:** [January 15, 2006, 11:27am UTC](https://www.ruby-forum.com/t/why-cant-i-changed-the-session-id-cookie/52437/2 "2006-01-15T11:27:10Z")

</div>

Woei S. wrote:

> Hi,
> 
> I noticed that there is a cookie set by my rails scaffold that contains  
> a 32 character hash code in it, but when I tried to change its value  
> using Cookies[:\_session\_id], nothing happened, it stays the same!
> 
> How am I supposed to change the session\_id?
> 
> Thanks.

I’ve noticed this too 😕

What is it you want to achieve? I spent a lot of time trying to wrap  
sessions in a separate permanent cookie because I had gotten the  
impression that there was no way of having Rails make the session cookie  
itself permanent. However, I eventually found that Rails _can_ do this:  
[http://wiki.rubyonrails.com/rails/pages/HowtoChangeSessionOptions](http://wiki.rubyonrails.com/rails/pages/HowtoChangeSessionOptions)  
(“changing session duration”).

---

<div class="post-metadata">

**Author:** ![generik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/4da419/32.png) [@generik](https://www.ruby-forum.com/u/generik)\
**Post date:** [January 17, 2006, 1:29am UTC](https://www.ruby-forum.com/t/why-cant-i-changed-the-session-id-cookie/52437/3 "2006-01-17T01:29:30Z")

</div>

Henrik wrote:

> I’ve noticed this too 😕
> 
> What is it you want to achieve? I spent a lot of time trying to wrap  
> sessions in a separate permanent cookie because I had gotten the  
> impression that there was no way of having Rails make the session cookie  
> itself permanent. However, I eventually found that Rails _can_ do this:  
> [Peak Obsession](http://wiki.rubyonrails.com/rails/pages/HowtoChangeSessionOptions)  
> (“changing session duration”).

What I was trying to do is to have each login generate a new session,  
because strictly speaking, if someone “steals” the cookie from a logged  
in browser and copies it elsewhere, he may be able to gain access to  
priviledged information too.

Not too sure how that’d pan out 😑
