Rails 3.2 session id nil until next request

Trying to connect rails 2 to rails 3, and I am having problems with sessions!

I cannot get a link to the session id during the login phase. I am looking at both request.session_options and the session, and there seems to be no session id assigned until the second request.

When the user logs in, I do session [: user_id] = user.id to put them in the session. I looked in the session table, and he definitely added session information here, but I want to be able to send the session identifier to the client, preferably with a response to the input.

It is worth noting that the next request, which I send after login and session, the request is created .session_options has good data, so it seems that everything happens, just not in the preferred order.

What is the best way to send a session id with login response?

Edit: the application that I create is an external program that talks to rails, so I cannot rely on browser cookies to work automatically.

+4
source share
1 answer

I came across this recently - see http://www.gani.com.au/2013/08/force-session-creation-in-rails/ . In the end, I forcibly created a session by writing to him.

session[:foo] = 'bar' 
+6
source

All Articles