2011-05-14 16:51:10 +02:00
|
|
|
# Be sure to restart your server when you modify this file.
|
|
|
|
|
2017-09-22 03:02:58 +02:00
|
|
|
module ActionDispatch
|
|
|
|
module Session
|
|
|
|
class SlugCookieStore < CookieStore
|
2023-05-12 13:01:12 +02:00
|
|
|
alias orig_set_cookie set_cookie
|
2017-09-22 03:02:58 +02:00
|
|
|
|
2020-09-04 12:57:19 +02:00
|
|
|
def set_cookie(request, session_id, cookie)
|
2017-09-22 03:02:58 +02:00
|
|
|
if script_name = FoodsoftConfig[:script_name]
|
|
|
|
path = request.original_fullpath[script_name.size..-1]
|
|
|
|
slug = path.split('/', 2).first
|
|
|
|
return if slug.blank?
|
2021-03-01 15:27:26 +01:00
|
|
|
|
2017-09-22 03:02:58 +02:00
|
|
|
cookie[:path] = script_name + slug
|
|
|
|
end
|
2020-09-04 12:57:19 +02:00
|
|
|
orig_set_cookie request, session_id, cookie
|
2017-09-22 03:02:58 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-09-04 12:57:19 +02:00
|
|
|
Rails.application.config.session_store :slug_cookie_store, key: '_foodsoft_session'
|
2011-05-14 16:51:10 +02:00
|
|
|
|
|
|
|
# Use the database for sessions instead of the cookie-based default,
|
|
|
|
# which shouldn't be used to store highly confidential information
|
2012-04-15 19:59:39 +02:00
|
|
|
# (create the session table with "rails generate session_migration")
|
|
|
|
# Foodsoft::Application.config.session_store :active_record_store
|