title: Rails 6 Session Data Not Persisting
body: <p>I've been battling this for about 24 hours now, and nothing I'm finding in my searches is leading to a solution.</p>
  <p>My issue is my session data is not persisting and I can not log in to my app.  Everything worked in Dev mode, but has not yet worked in Production.  I'm using a Rails 6 Api hosted on Heroku and a React front end.  I can successfully make the api call, find the user, and log them in using (I use &quot;puts&quot; to help me log the session at that instance.  The session hash has a session_id and user_id at this point):</p>
  <pre><code>def login!
      session[:user_id] = @user.id
      puts &quot;login_session: #{session.to_hash}&quot;
  end
  </code></pre>
  <p>After this the app redirects to the user page or an admin page depending on the users authorization.</p>
  <p>When the redirect happens that the user or admin page calls the api to see if the user is authorized using:</p>
  <pre><code>def logged_in?
      puts &quot;logged_in_session: #{session.to_hash}&quot;
      !!session[:user_id]
  end
  </code></pre>
  <p>The session is empty. Here is my sessions controller:</p>
  <pre><code>class SessionsController &lt; ApplicationController
  
  def create
      @user = User.find_by(email: session_params[:email])
      puts @user.inspect
      if @user &amp;&amp; @user.authenticate(session_params[:password])
          
        login!
        render json: {
          logged_in: true,
          user: UserSerializer.new(@user)
        }
      else
        render json: { 
          status: 401,
          errors: ['no such user', 'verify credentials and try again or signup']
        }
      end
  end
  
  
  def is_logged_in?
      if logged_in? &amp;&amp; current_user
        render json: {
          logged_in: true,
          user: UserSerializer.new(current_user)
        }
      else
        render json: {
          logged_in: false,
          message: 'no such user or you need to login'
        }
      end
  end
  
  def is_authorized_user?
      
      user = User.find(params[:user_id][:id])
      
      if user == current_user
          render json: {
              authorized: true
          }
      else
          render json:{
              authorized: false
          }
      end
  end
  
  
  def destroy
      logout!
      render json: {
        status: 200,
        logged_out: true
      }
  end
  
  def omniauth
    @user = User.from_omniauth(auth)
    @user.save
    login!
    render json: UserSerializer.new(@user)
  end
  
  private
  
  def session_params
      params.require(:user).permit(:username, :email, :password)
  end
  
  def auth
      
      request.env['omniauth.auth']
  end
  </code></pre>
  <p>Would any be able to point me the right direction??</p>
  <p>Thank you</p>