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

  • Home
  • SEARCH
  • 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 8322179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:17:36+00:00 2026-06-08T23:17:36+00:00

OK there are many simple session questions out there, but I can’t seem to

  • 0

OK there are many “simple session” questions out there, but I can’t seem to find what I’m after. It bugs me a little bit as the PHP document does not seem to explain this well.

Three fold questions.

  1. It says that session_destroy() wipes out the session data but not the global variable. So it wipes the data but the variables are still in tact? What does the documentation mean by global variables?

  2. What are the different types of ways that I can use to destroy session data, isn’t session_destroy enough? Why would you use the below coding as I’ve seen in some code examples:

    session_start();
    $_SESSION = array();
    session_destroy();
    
  3. Session seem to persist across browser instances. For example, IE9 will keep the same session id when two separate browsers are opened. Same with Chrome. Only when I close all the browsers, will I get a new session id. Is this always the case for all browsers? I want to know so that I can keep this in mind during my coding – wouldn’t want to find out later that some browsers are not persistent and my code thinks that it does, then run the risk of producing all sorts of errors.

Thanks in advance for anyone who can help me answer these questions.

  • 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-08T23:17:39+00:00Added an answer on June 8, 2026 at 11:17 pm
    1. $_SESSION is the super global variable
    2. The session_destroy function is basicly enough. It deletes the session_file on the server where all session-variables are stored and removes the session-cookie. The variables are after the session_destroy call still in the memory, but changing these values has no effect (except you call session_start() again).

      But the code snippet removes the variables from the memory too. This is important if for example the application checks for $_SESSION['admin'] later in the same request to see if the user has admin rights.

      The session_start() function is needed because you need to load the session first to delete it.

    3. Sessions are not persistant across diffrent browsers, however they are persistant across all windows/tabs of the same browser. What happens if you close the browser really depends on your PHP-ini setting. session.cookie_lifetime defines how long (in seconds) the browser should keep the cookie (even after restart). If session.cookie_lifetime is set to 0 the browser deletes the session cookie when closing.

      session.gc_maxlifetime defines how long the webserver keeps the session file (without the session file the session-cookie is invalid)

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

Sidebar

Related Questions

There are many questions like this but I can't find one that seems to
There are many similar questions, but I didn't find one that gets straight to
This should be very simple question. There are many programming languages out there, compiled
ok I am well aware there are many other questions about this, but I
There are many solutions for third-party decentralized authentication that are pretty simple to set
I have a simple setup, where there are Products and Images. Products have many
There were many questions about C++ template classes which contain static member variables, as
There are many errors here in SO, but this scenario I think its different.
There are many similar questions, however they don't answer the problem of a url
There are many many posts and an infinite number of questions on how to

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.