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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:31:56+00:00 2026-05-29T09:31:56+00:00

Strange issue. This is index.php: session_start(); print_r($_COOKIE); print_r($_SESSION); This is logout.php: session_destroy(); $_COOKIE[‘key’] =

  • 0

Strange issue.

This is index.php:

session_start();
print_r($_COOKIE);
print_r($_SESSION);

This is logout.php:

session_destroy();
$_COOKIE['key'] = "";
$_COOKIE['usr_email'] = "";
setcookie("key", "", time() - 3600);
setcookie("usr_email", "", time() - 3600);
header("Location: http://www.site.net/index.php");

When I load logout.php, after being redirected to index.php I get:

Array
(
    [fc] => fcVal=6927578914025605120
    [PHPSESSID] => na015ipu3s69hhj00sgd0h1es6
)
Array
(
    [key] => cc2bffe0c1e36bc5790f5b78b11e5f50
    [usr_email] => myemail@gmail.com
)

Sessions are ok as I generate them when I load index.php, but how are the cookie still present?

Note

I have some more code on index.php that determines if the login form was filled and starts to authenticate the user, if the user/pass are correct it sets two session vars and two cookie vars (usr_email and key).

At the moment, I’m after the login form, so I have both cookies and session vars and since the cookies were not being deleted, I disabled every other PHP code that was on the index page as I thought maybe something is automatically logging me in. So currently I have authenticated and then commented out the rest from the index page that is not what mentioned above.

Also relevant
This is how I set the cookies when a user is authenticated:

    setcookie("key", $cookie['key'], time() + 36000);
    setcookie("usr_email", $cookie['usr_email'], time() + 36000);

PHP Version: PHP 5.3.6-13

Last edit

As Josh wrote in the comments, I was confusing the cookie print with the session, I wasn’t able to delete the session vars and not the cookie vars.

  • 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-29T09:31:57+00:00Added an answer on May 29, 2026 at 9:31 am

    From the PHP Manual:

    … [session_destroy()] does not unset any of the global variables associated with
    the session, or unset the session cookie…

    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.

    Note: PHPSESSID is the cookie propagating the session ID.

    Try the following to clear your session variables from being reused:

    // Example #1 Destroying a session with $_SESSION
    // Initialize the session.
    // If you are using session_name("something"), don't forget it now!
    session_start();
    
    // Unset all of the session variables.
    $_SESSION = array();
    
    // If it's desired to kill the session, also delete the session cookie.
    // Note: This will destroy the session, and not just the session data!
    if (ini_get("session.use_cookies")) {
        $params = session_get_cookie_params();
        setcookie(session_name(), '', time() - 42000,
            $params["path"], $params["domain"],
            $params["secure"], $params["httponly"]
        );
    }
    
    // Finally, destroy the session.
    session_destroy();
    

    Note: session_start() must be called before session_destroy() can work.

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

Sidebar

Related Questions

I have this strange issue with my web app. You see, I'm using jQuery
This is a really strange issue. One day my project started to do a
Very strange issue... I have something like this in my Controller: public ActionResult Initialize(IEnumerable<MyModel>
I ran into a strange issue with my indexed tableview's section index titles. The
I have a very strange issue with facebook-connect within my PHP-Webapplication. From one day
I came across this strange issue at work so I created a minimal app
We had a very strange issue on our servers this week, where a method
Please help! I have a strange issue here. DEMO The issue in this gallery
I have some strange issue with isset() function in PHP. Let me show... .
This is a very strange issue I am facing for a while now, when

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.