title: AngularJS / Rails mobile session only last an hour
body: <p>Why do mobile sessions last an hour but desktop don't expire. </p>
  
  <p>I'm simply setting the cookie with: </p>
  
  <pre><code>// app.run
  $http.defaults.headers.common['X-CSRF-Token'] = $cookies.get('csrftoken');
  </code></pre>
  
  <p>This works perfectly fine on desktop (many months) but with mobile it only lasts ~1 hour. Why does this happen? Do you need to set cookies differently on mobile (tested in both safari and chrome for iOS)? It's not because a user closes the tab because you can close and re-open and still have the session. </p>
  
  <p>Finally, what is the solution to this problem to keep users logged in for say 30 days? LocalStorage?</p>
  
  <pre><code>ApplicationController
  
    protect_from_forgery with: :exception
    after_action :set_csrf_cookie_for_ng
  
    def set_csrf_cookie_for_ng
      cookies['csrftoken'] = form_authenticity_token if protect_against_forgery?
    end
  </code></pre>