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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:24:17+00:00 2026-05-26T14:24:17+00:00

I have searched many questions regarding session_destroy and the often response from the answerers

  • 0

I have searched many questions regarding session_destroy and the often response from the answerers involve quoting directly from the PHP manual which states the following:

session_destroy() destroys all of the data associated with the current
session. It does not unset any of the global variables associated with
the session, or unset the session cookie. To use the session variables
again, session_start() has to be called.

In order to kill the session altogether, like to log the user out, the
session id must also be unset. If a cookie is used to propagate the
session id (default behavior), then the session cookie must be
deleted. setcookie() may be used for that.

In a question asking “What is the difference between session_unset() and session_destroy() in PHP?“, the answerer mentions about $_SESSION variable and session storage but never go deep enough.

I think a lot of confusion arising from the function session_destroy is due to the lack of understanding regarding session data and mixing it up with $_SESSION variable. I would like to know what is the actual purpose of session data if $_SESSION variable already contains that data?

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-26T14:24:17+00:00Added an answer on May 26, 2026 at 2:24 pm

    Simplified answer:

    The purpose for $_SESSION is to store data that you (as the web application developer) would like to have preserved across page loads. Thus, you can set flags in your login script such as logged_in to check if the user is logged in, and on any other page check $_SESSION['logged_in'] == true, instead of querying for that information.

    Your OP seems to assume that data is automagically present in $_SESSION. You as the developer determine what is placed in $_SESSION, it is not done for you.

    Hope this helps.

    Edit: I see. The data in the file stored at session.save_path is where PHP saves the information you store into the $_SESSION array. This is how PHP can reload the $_SESSION data across page loads. So, when a script begins execution and calls session_start, PHP fetches the appropriate data from the file at session.save_path and loads it into $_SESSION.

    At the start of a page’s execution, the data in session.save_path and $_SESSION are identical. However, the script may add or remove data from $_SESSION, which will eventually cause the file at session.save_path to be updated so that it reflects the changes made to $_SESSION.

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

Sidebar

Related Questions

I have searched many questions on ObjC accessors and synthesized accessors to no avail.
I have searched a lot and beleive me i have come across many questions
I have searched for IO issue in forums and found many questions on the
I have searched the internet far and wide and seen many questions like this,
First of all I have searched many times in this forum but none is
This is my fort post on stackoverflow. I have searched many similiar Q&A's on
I want to use bar chart in web application. I have searched many libraries
I have searched through many times but have not seen this before. Probably really
Yes, I have searched and tried many techniques, but nothing seems to work. Here
I realise this may be a duplicate, but I have searched through many forums

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.