Keep the user on when the mobile browser closes (Rails)

Users on mobile devices log out when they close the browser, and I would like them to log in.

I read that this can be solved using cookies, but we are already doing this.

Rails.application.config.session_store :cookie_store, key: '_app_session'

Also using

devise :rememberable

In addition, I could not find a specific example of the implementation of cookies directly in Devise::SessionsController.

Any help would be greatly appreciated.

Update

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

Update

I can change the modification or change the configuration of Rails for this to work.

It looks like in googling I get the default result.

Update

Adding gemfile.rb for each 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'
+6
source share
1

expire_after

Rails.application.config.session_store :cookie_store, key: '_app_session', expire_after: 3.hours
+1

All Articles