From 3d29e6e67df5d46d0250d330219a00726d68968f Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Fri, 22 Dec 2023 12:58:34 +0200 Subject: [PATCH] change timelife cookie banner --- app/controllers/cookies_controller.rb | 22 ++++++++++++++++------ app/helpers/application_helper.rb | 4 ++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/app/controllers/cookies_controller.rb b/app/controllers/cookies_controller.rb index f3019b5ae..120806cc4 100644 --- a/app/controllers/cookies_controller.rb +++ b/app/controllers/cookies_controller.rb @@ -1,12 +1,22 @@ class CookiesController < ApplicationController def update - session[:cookie_dialog] = 'accepted' - session[:google_analytics] = if params[:cookies] == 'accepted' || params[:analytics_selected] == '1' - 'accepted' - else - 'declined' - end + cookies[:cookie_dialog] = { + value: "accepted", + expires: 1.year.from_now, + } + cookies[:google_analytics] = if params[:cookies] == 'accepted' || params[:analytics_selected] == '1' + { + value: "accepted", + expires: 1.year.from_now, + } + else + { + value: "declined", + expires: 1.year.from_now, + } + end + redirect_to root_path end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f1013f48e..2888e7aaa 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -49,11 +49,11 @@ def end_of_procdure end def show_cookie_dialog? - session[:cookie_dialog] != 'accepted' + cookies[:cookie_dialog] != 'accepted' end def show_google_analytics? - session[:google_analytics] == 'accepted' + cookies[:google_analytics] == 'accepted' end private