title: Devise Omniauth-Facebook rememberable
body: <h2>Problem</h2>
  
  <p>I have <strong>Devise Omniauth-Facebook</strong> authentication. The log in with facebook works, but the Session is lost when the user goes to <code>localhost:3000</code>.
  I have the following <strong>GEMs</strong>:</p>
  
  <pre><code>Devise 4.2.0
  Rails 5
  omniauth 1.4.0
  omniauth-facebook 4.0.0
  omniauth-oauth2 1.4.0
  </code></pre>
  
  <h2>Description</h2>
  
  <p>The Session works correctly for users not authenticated with Omniauth-Facebook, </p>
  
  <p>This is my <code>devise.rb</code> omniauth-facebook <strong>settings</strong>:</p>
  
  <pre><code>config.omniauth :facebook, "APP_ID", "APP_SECRET", callback_url: "http://127.0.0.1:3000/users/auth/facebook/callback", scope: 'public_profile, email', image_size: 'large', provider_ignores_state: true 
  </code></pre>
  
  <p>I already tried the following solution that did not work:</p>
  
  <ol>
  <li>turning off protect_from_forgery</li>
  <li>OmniAuth.config.full_host = "<a href="http://127.0.0.1:3000" rel="nofollow noreferrer">http://127.0.0.1:3000</a>" </li>
  <li>Following the accepted solution of Jeroen van Dijk at the following post:
  <a href="https://stackoverflow.com/questions/4475726/devise-and-omniauth-remembering-oauth">Devise and OmniAuth remembering OAuth</a>
  For this solution, in my rake routes I do not have the path <code>user_oauth_connect_path</code>, even if I added the route in <code>routes.rb</code>. I also think this is not the solution to my problem because I have Devise 4.2.0 and Rails 5</li>
  <li>@user.remember_me = true</li>
  </ol>
  
  <p>All the previous solutions were taken from the following stackoverflow discussions: </p>
  
  <p><a href="https://stackoverflow.com/questions/5816294/omniauthfacebook-lost-session">Omniauth+Facebook lost session</a></p>
  
  <p><a href="https://stackoverflow.com/questions/4475726/devise-and-omniauth-remembering-oauth">Devise and OmniAuth remembering OAuth</a></p>
  
  <p>The code is the standard one included in the guides from github of <em>Devise</em> and <em>omniauth-facebook</em>
  Thanks a lot for your help
  Fabrizio Bertoglio</p>