# Specifying session\_id in params?

**URL:** <https://www.ruby-forum.com/t/specifying-session-id-in-params/159898>\
**Category:** Rails\
**Created:** [February 9, 2009, 9:42pm UTC](https://www.ruby-forum.com/t/specifying-session-id-in-params/159898 "2009-02-09T21:42:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [February 9, 2009, 9:42pm UTC](https://www.ruby-forum.com/t/specifying-session-id-in-params/159898/1 "2009-02-09T21:42:12Z")

</div>

I am using a Flex based front end on top of a rails backend. When the  
SWF is first loaded from the rails app to the client’s browser, a  
session is created on the rails side.

However, subsequent requests from the loaded Flex app are also creating  
whole new sessions as well. I need the flex app’s calls to continue  
using the existing session.

So I am sending the flexapp the original session id, and am then  
appending that session id into the params when it sends it back. Is  
there anything else you need to do besides inserting the specific  
session id into the request params to get rails to use that session id  
instead of making a new one? If it makes a difference, this is a  
multipart post from the flex app back to the rails server.

Here is an example sequence of events – the first request is what  
serves the SWF to the client’s browser:

Processing MainController#index (for 127.0.0.1 at 2009-02-09 15:31:44)  
[GET]  
Session ID: ff99a1a31c21bcd247390e8c54b65dc9

Next, I am doing a callback from within the flex SWF as a multipart post  
request, with the “\_session\_id” parameter specified:

Processing ApiController#upload (for 127.0.0.1 at 2009-02-09 15:32:05)  
[POST]  
Session ID: c104c28b75d712f3dd81f59dd39d963d  
Parameters: {“Filename”=\>“att2.jpg”,  
“\_session\_id”=\>“ff99a1a31c21bcd247390e8c54b65dc9”, “action”=\>“upload”,  
“Upload”=\>“Submit Query”, “controller”=\>“api”, “fb\_sig\_user”=\>“null”,  
“Filedata”=\>#\<File:/var/folders/h2/h228JZQKHUmVvaxHLCmPh++++TM/-Tmp-/CGI.350.3\>}

As you can see, the “\_session\_id” parameter in the 2nd request matches  
the first requests Session ID. However, the 2nd request clearly is  
getting a different session.

Any ideas?

---

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [February 10, 2009, 1:03am UTC](https://www.ruby-forum.com/t/specifying-session-id-in-params/159898/2 "2009-02-10T01:03:41Z")

</div>

On 9 Feb 2009, at 20:42, Brian Culler wrote:

> So I am sending the flexapp the original session id, and am then  
> appending that session id into the params when it sends it back. Is  
> there anything else you need to do besides inserting the specific  
> session id into the request params to get rails to use that session id  
> instead of making a new one? If it makes a difference, this is a  
> multipart post from the flex app back to the rails server.

Reading the session\_id from the params is turned off by default. Try  
setting the cookie\_only option to false (and make sure that the  
session\_key option matches whatever flex is sending)

Fred
