Deleting the current session with Rack::Session::Cookie Deleting the current session with Rack::Session::Cookie ruby ruby

Deleting the current session with Rack::Session::Cookie


Just use

session.clear

to destroy the session.


It depends how you create your session. Simply you have to nulify session entry. Here is simple example, how to create and destroy sessions.

  get '/login' do    session[:username] = params[:username]    "logged in as #{session[:username]}"  end  get '/logout' do    old_user = session[:username]    session[:username] = nil    "logged out #{old_user}"  end

You can also check this example: https://gist.github.com/131401