# Error with session ids in integration tests (Rails 2.0.x)?

**URL:** <https://www.ruby-forum.com/t/error-with-session-ids-in-integration-tests-rails-2-0-x/126253>\
**Category:** Rails\
**Created:** [January 16, 2008, 7:46pm UTC](https://www.ruby-forum.com/t/error-with-session-ids-in-integration-tests-rails-2-0-x/126253 "2008-01-16T19:46:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Michael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c37758/32.png) [@David\_Michael](https://www.ruby-forum.com/u/David_Michael)\
**Post date:** [January 16, 2008, 7:46pm UTC](https://www.ruby-forum.com/t/error-with-session-ids-in-integration-tests-rails-2-0-x/126253/1 "2008-01-16T19:46:18Z")

</div>

Hello list

In writing integration tests dealing with session variables, I am  
coming across some interesting behavior. It seems that the session id  
changes after every request.

class RatingIntegrationTest \< ActionController::IntegrationTest  
def test\_anonymous\_rating

```
open_session do |sess|
  sess.post "/rating/create?

```

rating[rating]=5&rating[video\_id]=#{ default\_video.id }"

```
  ## THIS GIVES ONE RESULT
  puts sess.cookies["_myapp_session_id"]

  sess.post( "/rating/create?

```

rating[rating]=1&rating[video\_id]=#{ default\_video.id }" )

```
  ## THIS GIVES ANOTHER RESULT!
  puts sess.cookies["_myapp_session_id"]
end

```

end  
end

Is there a better way to get the session id?  
Is this code incorrect?

Thanks in advance,  
David

---

<div class="post-metadata">

**Author:** ![David\_Michael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c37758/32.png) [@David\_Michael](https://www.ruby-forum.com/u/David_Michael)\
**Post date:** [January 29, 2008, 3:14pm UTC](https://www.ruby-forum.com/t/error-with-session-ids-in-integration-tests-rails-2-0-x/126253/2 "2008-01-29T15:14:55Z")

</div>

Hi David  
I am having the same issue when I try to use my own authentication  
method. the Seesion Id Changes at certain POST requestsand I loose my  
authentication. If you have found a solution please post it.

WW
