I have my app keep state with a session variable in my DB:
session :session_key => ‘_myapp_session_id’
This works find when I login and run my app via my browser.
But when I login via curl, the session doesn’t seem to work, and once
I call a action that need authentication, the can’t find my session
variable. I checked my DB and a row is added everytime I login via
curl, but the rest of my app can’t seem to read the session variable.
What’s going on? Does the session[] only work via a web browser?
What’s going on? Does the session[] only work via a web browser?
You will most likely need to tell CURL to use the cookie set on login.
Google curl + cookie and there are a few explanations on what is
required. Alternatively you can try and change you app to not use
cookies for tracking sessions (not sure how hard that is in rails).
Anyway I think you can get curl to save the cookie to a file and then
use that in subsequent requests. But I haven’t done it myself.
So to save the cookie when you login use curl -c [cookie-file-path]
this saves the cookie text file to your current directory.
Then to reference your cookie in subsequent calls use curl -b [cookie-
file-path]
----- Original Message -----
From: “eggie5” [email protected]
To: “Ruby on Rails: Talk” [email protected]
Sent: Monday, September 10, 2007 8:59 PM
Subject: [Rails] why doesn’t my session work when I run my app via curl
Yes, thanks for the previous post. I did learn something after all
– Long
----- Original Message -----
From: “eggie5” [email protected]
To: “Ruby on Rails: Talk” [email protected]
Sent: Monday, September 10, 2007 10:49 PM
Subject: [Rails] Re: why doesn’t my session work when I run my app via
curl
– Longhttp://MeandmyCity.com/- Find your wayhttp://edgesoft.ca/blog/read/2- No-Cookie Session
Support plugin
No, I figured out how to do it with curl. It’s not too bad. I just
wonder how valid the use of cookies would be for an API… I’m pretty
sure any environment would support cookies: C#, java, ruby, flex…
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.