Problem with session on ajax request

Guys, i’m having a problem similar with those reported with rails 3.0.4 and sessions with ajax requests.

The problem is that i have an action that receives an ajax POST and sets an session.

def test

session[:user] = me

end

but the session vanishes and don’t become available in the next request.

The routes are OK, and anything else are working fine.

I don’t believe that this relates to the csrf-token problem of rails 3.0.4 because the token is passed to rails by jquery. And indeed i can access the session hash from within the POST request . But anything I include in the session (within the POST request) is propagate to the next request.

If anyone can help me i would be very thankful.

Dimas Cyriaco

Excuse me, i have a typo in the text. What i was trying to say is that anything I include in the session (within the POST request) is NOT propagate to the next requests.

Anyone?

Have you tried looking at the request/response headers to see where
the problem is (eg is rails not setting the session cookie, is the
browser ignoring it, is rails ignoring it on subsequent requests
etc) ? What is the me object?

Fred

The session is working fine. During the ajax request i can read the session normally. But anything i write to it does not shows up in the next requests.

In all other scenario it works great.

I can reproduce this situation any time just by creating an empty project (rails 3.0.8) with an simple scaffold. Put an ajax request on the onload event (of, say, the index page) that calls any action of the controller (say the edit action).

If i write anything to the session on the index action i can read it in the edit action. But if i write to the session on the edit action (during the ajax call) then, the next time i hit the index action, it doesn’t show what i wrote on the edit action. Very strange.

Btw, the me object is just a string.

Thanks

I have the exact same problem, did you solve it?
what did you do??