Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6661647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:18:19+00:00 2026-05-26T02:18:19+00:00

Why does my flash[:notice] appear permanently on the redirected page? – Rails 3.1 In

  • 0

Why does my flash[:notice] appear permanently on the redirected page? – Rails 3.1

In my ApplicationController I have this before_filter:

before_filter   :expire_session

def expire_session
  if session
    reset_session if session[:last_seen] < 15.minutes.ago
    flash[:error] = "Your session has timed out. Please log back in."
    session[:last_seen] = Time.now
  end
end

In my sessions_controller, these are the error and destroy actions:

  def error
    flash[:error] = "We're sorry. You need to sign in to get access to that page."
    redirect_to root_path
  end

  def destroy
    reset_session
    redirect_to root_path, :notice => "Signed out!"
  end

It works perfectly, i.e. it expires my session after X minutes of inactivity – which is what I want. The issue is, when it redirects me to the root_path, it has this message:

Your session has timed out. Please log back in.

If I reload the page, the message is still there. If I close the tab and come back to that URL, that message is still there.

The other messages generated in flash[:notice] or flash[:error] display only once and when you reload the page, they are gone.

Why is this one sticking around?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:18:20+00:00Added an answer on May 26, 2026 at 2:18 am

    Try to rewrite expire method:

    before_filter   :expire_session
    
    def expire_session
      if session && session[:last_seen] < 15.minutes.ago
        reset_session
        flash[:error] = "Your session has timed out. Please log back in."
      elsif session
        session[:last_seen] = Time.now
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code : def create login(params[:email], params[:password]) if current_user flash[:notice] = Welcome
Hi I ran in this issue a while ago... authlogic flash[:notice] does not show
I want to render my Rails flash[:notice] and flash[:error] messages in a bar at
I have a rails app, for some reason my login action does not work.
Does flash.display.Loader determine the file by filename or header? The reason why I ask
Does flash.security.allowDomain(*) allow for redirects? The reason why I ask is that I'm trying
does Flash comply with HTTP Location headers? For example, if Flash makes a POST
How does Flash communicate with services / scripts on servers via AMF ? Regarding
Does anyone know how to pause a VPAID flash ad using the actionscript 3
Does anybody know of a free flash obfuscator(protector)? All I can find are commercial

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.