Module: MultiModelWizard::CookieStore

Extended by:
ActiveSupport::Concern
Included in:
RedisCookieStore, Wizard
Defined in:
lib/multi_model_wizard/cookie_store.rb

Constant Summary collapse

EXPIRATION =
1.hour

Instance Method Summary collapse

Instance Method Details

This method is used to delete the session cookie from the browser



31
32
33
# File 'lib/multi_model_wizard/cookie_store.rb', line 31

def delete_cookie(key)
  cookies.delete(key.to_sym)
end

This method is used to retrieve the session cookie from the browser



26
27
28
# File 'lib/multi_model_wizard/cookie_store.rb', line 26

def get_signed_cookie(key)
  cookies.signed[key.to_sym]
end

This method is used to set the session cookie on the browser EXAMPLE: set_signed_cookie(key: ‘multi_model_wizard_form’, value: { hello: ‘world’ })



15
16
17
18
19
20
21
22
23
# File 'lib/multi_model_wizard/cookie_store.rb', line 15

def set_signed_cookie(attributes)
  cookies.signed[attributes[:key]&.to_sym] = {
    value: attributes[:value],
    expires: attributes[:expires] || EXPIRATION.from_now,
    same_site: attributes[:same_site] || 'None',
    secure: attributes[:secure] || true,
    httponly: attributes[:httponly] || true
  }
end