module Sinatra::SessionHelpers::Helpers
Public Instance Methods
session!()
click to toggle source
Redirects the client to the URL given in the session_fail
setting if session?
returns false
.
# File lib/sinatra/session_helpers.rb, line 28 def session! redirect(settings.session_fail) unless session? || settings.session_fail == request.path_info end
session?()
click to toggle source
Returns true
if the current session is valid, false
otherwise.
# File lib/sinatra/session_helpers.rb, line 23 def session? !! session[:authorized] end
session_end!(destroy=true)
click to toggle source
After this method is called, calls to session?
will return false
. If you want to keep the old session data around in the cookie for some reason, set destroy
to false
.
# File lib/sinatra/session_helpers.rb, line 14 def session_end!(destroy=true) if destroy session.clear else session[:authorized] = false end end
session_start!()
click to toggle source
After this method is called, calls to session?
will return true
.
# File lib/sinatra/session_helpers.rb, line 9 def session_start! session[:authorized] = true end