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 7984399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:15:28+00:00 2026-06-04T11:15:28+00:00

I have a few $_SESSION variables that keep track of what page the user

  • 0

I have a few $_SESSION variables that keep track of what page the user comes from. This way, I can make the error messages more specific and thus the web app more user friendly. When a user does not come from any page, there is supposed to be a “welcome” message at the top of the main page. However, when I close the browser and access the main page, I get the message corresponding to the page I linked from prior to closing the session. This is my function:

function come_from($from_page, $updates_occurred) { 
    $message = "";
    if ($updates_occurred == false) {
        $message .= "Welcome to the User List.<br/>";
        $message .= "Select the user you wish to update, or add a new user. ";
    } elseif ($from_page == "edit_user.php") {
        $message .= "The user was successfully updated";
    } else { 
        $message .= "The user was successfully added";
    }
return $message; 
}

At the top of the main page, I have the following code:

if (isset($_SESSION['updates_occurred'])) {
    $updates_occurred = $_SESSION['updates_occurred'];
} else {
    $updates_occurred = false;
}

if (isset($_SESSION['come_from'])) {
    $come_from = $_SESSION['come_from'];
} else {
    $come_from = NULL;
    echo "got here";
}


echo come_from($come_from, $updates_occurred); 

*updates_occurred just keeps track of whether a user was successfully edited/added on the previous page.

I guess my main concern is: is there a problem with the way I am using the session variables? If my understanding is correct, session variables are supposed to expire when the browser is closed, right?

  • 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-06-04T11:15:29+00:00Added an answer on June 4, 2026 at 11:15 am

    Closing Browser tabs doesn’t close the session

    You should close whole browser to close the session

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web app that has a few processes that can take up
I have a few variables that are assigned the values of session variables (See
I have a few pages on my site that are protected from invalid access
Is there any scenario where a client/user/hacker can set $_SESSION variables themselves (excluding malicious
I have a few classes that are instantiated using ninject Session Scoping - because
I have a CI app that uses db sessions, and a few hundred users
I have a public class that only contains public static members. I know this
I have a CI controller that outputs some JS variables (mainly language variables). I
In my asp.net application I have a few session variables. Seems like only a
I need to have a few variables accessible on almost every view. I think

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.