Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 4 session values not persisting after redirect #670

Closed
beerlington opened this issue Mar 12, 2013 · 4 comments
Closed

Rails 4 session values not persisting after redirect #670

beerlington opened this issue Mar 12, 2013 · 4 comments

Comments

@beerlington
Copy link

I'm having an issue where session values that I set in the SessionsController are not persisted when users are redirected to a different page.

In the following controller, I am setting the user_id and redirecting to a different controller's action. When execution gets to that controller, the value I previously set is no longer available. Similar logic works in a Rails 3.2 application so I'm not sure if it's a problem with OmniAuth or what.

class SessionsController < ApplicationController
  skip_before_filter :authenticate_user!

  def create
    user = User.find_or_create_by_auth_hash(auth_hash)
    session[:user_id] = user.id
    redirect_to root_path
  end

  protected

  def auth_hash
    request.env['omniauth.auth']
  end

end
@beerlington
Copy link
Author

This seems to only be an issue with the developer strategy. omniauth-linkedin does not have the same problem.

@tmilewski
Copy link
Member

Added to FAQ. Thanks!

@jshou
Copy link

jshou commented Dec 25, 2014

I'm seeing a similar issue with the omniauth-google-oauth2 strategy, where sign_in_and_redirect @user, :event => :authentication doesn't seem to persist the user. Setting the session's user_id manually as mentioned above seems to solve the problem.

@jlkwarteng
Copy link

Currently Experiencing the very same issue. Although i'm not working with omniauth session variables i set do not persist to the next controller on redirect in rails

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants