Forum: Ruby on Rails Login Authentication working in IE but not in Mozilla

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
535eb0617348da39410f63de18ae6f22?d=identicon&s=25 Surjya Hazarika (prasad)
on 2005-11-25 05:25
  I have gone through the following site for the creation of my login
page:
To mention I am using Windows XP pfofessional running on WEBBrick server

http://wiki.rubyonrails.com/rails/pages/HowtoAuthenticate

The code is given in the following 3 steps:

1)The controller that needs protection:

class WeblogController < ActionController::Base
  before_filter :authenticate

  def index
    # show the secret stuff
  end

  protected
    def authenticate
      unless @session["person"]
        @session["return_to"] = @request.request_uri
        redirect_to :controller => "login"
        return false
      end
    end
end

2)The controller that does login:

class LoginController < ActionController::Base
  def index
    # show login screen
  end

  def authenticate
    if @session["person"] = Person.authenticate(@params["name"],
@params["password"])
      if @session["return_to"]
        redirect_to_path(@session["return_to"])
        @session["return_to"] = nil
      else
        redirect_to :controller => "weblog"
      end
    else
      flash["alert"] = "Login failed!"
      redirect_to :action => "index"
    end
  end

  def logout
    reset_session
    flash["alert"] = "Logged out"
    redirect_to :action => "index"
  end
end

3)The model that does authentication:

class Person < ActiveRecord::Base
  def self.authenticate(name, password)
    find(:first,
      :conditions => [ "name = ? AND password =?", name, password ]
    )
  end
end

 My problem is that the above code works properly in Internet Explorer
browser but fails to work in Mozilla browser. What I mean to say is that
once I logout using a link_to in my home page I call the logout function
in my login controller and reditrect to my login or index page. Now if I
click on the back button, it still takes me to the home page. This
should not happen as the session has already been destroyed. In Internet
Explorer, there's no problem at all. In IE if I click the back button
after logging out it redirects me to the index page and not to the home
page.
    Kindly help me out in this regard..
Thanks and regards..
Surjya Prasad Hazarika,
Trainee Software Engineer,
Genie Interactive,
Bangalore
This topic is locked and can not be replied to.