Users on mobile are being logged out when they close their browser, and I would like to keep them logged in.
I read this could be solved by using cookies but we're already doing that.
Rails.application.config.session_store :cookie_store, key: '_app_session'
Also using
devise :rememberable
Additionally I wasn't able to find a specific example of implementing cookies directly in Devise::SessionsController.
Any assistance would be very appreciated.
user.rb
class User < ApplicationRecord
  devise :two_factor_authenticatable, :database_authenticatable,
         :registerable, :timeoutable, :confirmable, :invitable,
         :recoverable, :rememberable, :trackable, :omniauthable,
         omniauth_providers: [:linkedin]
  has_one_time_password(encrypted: true)
  def only_if_unconfirmed
    pending_any_confirmation { yield }
  end
  def timeout_in
    setting.custom_timeout.to_i.seconds
  end
  ...
end
I'm open to modifying devise, or changing Rails configuration to make this work.
It seems from googling that the result I'm getting is default behavior.
Adding gemfile.rb per request.
source 'http://rubygems.org'
ruby '2.4.0'
gem 'comfortable_mexican_sofa'
gem 'exception_notification'
gem 'ransack'
gem 'selectize-rails'
gem 'bitly', '~> 0.10.4'
gem 'yomu', '~> 0.2.4'
gem 'pg'
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
gem 'puma', '~> 3.0'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'kaminari'
gem 'jquery-rails'
gem 'turbolinks', '~> 5'
gem 'jquery-turbolinks'
gem 'jbuilder', '~> 2.5'
gem 'foundation-rails'
gem 'foundation_rails_helper', git: 'https://github.com/sgruhier/foundation_rails_helper'
gem 'inky-rb', require: 'inky'
gem 'premailer-rails'
gem 'redis', '~> 3.0'
gem 'redis-rails', '~> 5'
gem 'resque'
gem 'paper_trail'
gem 'devise'
gem 'omniauth-oauth2', '~> 1.3.1'
gem 'omniauth-linkedin-oauth2'
gem 'omniauth-google-oauth2'
gem 'devise_invitable'
gem 'two_factor_authentication'
gem 'valid_email2'
gem 'geocoder'
gem 'twilio-ruby'
gem 'omnicontacts'
gem 'sparkpost_rails'
gem 'raygun4ruby'
gem 'bonsai-elasticsearch-rails'
gem 'elasticsearch-rails'
gem 'elasticsearch-model'
gem 'searchkick', git: 'https://github.com/ankane/searchkick'
gem 'ahoy_matey'
gem 'blazer'
gem 'subdomain_router'
gem 'figaro'
gem 'paperclip', git: 'https://github.com/thoughtbot/paperclip'
gem 'dropzonejs-rails'
gem 'aws-sdk'
gem 'cocoon', '~> 1.2.9'
gem 'haml-rails', '~> 0.9'
gem 'newrelic_rpm'
gem 'pdf-reader'
gem 'clearbit'
gem 'httparty'
gem 'friendly_id', '~> 5.1.0'
gem "octokit", "~> 4.0"
group :development, :test do
  gem 'pry'
  gem 'byebug', platform: :mri
  gem 'erb2haml'
  gem 'haml_lint'
  gem "letter_opener"
end
group :development do
  gem 'web-console'
  gem 'listen', '~> 3.0.5'
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
  gem 'bullet'
  gem 'derailed'
end
group :test do
  gem 'rspec-rails'
  gem 'factory_girl_rails'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'heroku-deflater', :group => :production, git: 'https://github.com/romanbsd/heroku-deflater.git'
gem 'chartkick'
gem 'groupdate'
Add expire_after
Rails.application.config.session_store :cookie_store, key: '_app_session', expire_after: 3.hours
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With