Ruby and Sinatra problems with session -


i used sinatra session in ruby project. after login write in session[:name] name of user. if user call api method verify session[:name] , if value not empty response server. after logout clear value. code:

 use rack::session::cookie, :expire_after => 86400      '/login'         session[:name] = params[:username]     end      '/logout'         session[:name] = ''         return 'done'     end      error 401       return '401 unauthorized'     end      '/check_session'         if session[:name].to_s.strip.length == 0 || session[:name].to_s!=params[:username]             return 401         end         return session[:name]     end 

this code works good. if login 1 browser, i.e. google chrome, , after open anther browser, i.e. mozilla firefox , call /check_session response server 401 unauthorized. why happen? , how fix it?

its not bug. each browser making own session. , need login after open page in new browser.


Comments