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?
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?
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]
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...