Session is not set until the page reload

I work with Rails remote form. After set the session like session[:user_id] = 123 , the session is still blank {} . After I refreshed page, I got the user_id value. How can I access those session without refreshing page?

Can you please share some more context and possible your Controller and View code fragments/examples? It’s hard to be sure without them.