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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:34:41+00:00 2026-05-17T17:34:41+00:00

I am at a total loss for words. I allow an admin to reset

  • 0

I am at a total loss for words.

I allow an admin to reset their registration if reaching an error during the process. In theory, the following code should function like this:

page is reached, $adminvalidated is set based on session data. The $_SESSION array is cleared; the cookie is cleared on the consumer end; the session id is regnerated and the session is destroyed. Then the session is restarted and the previously mentioned variable is put back into Session.

the “echo” statements included below work but when I redirect to another page (commented out below), the session variables DO NOT carry over.

Yes I have started the session on the follow up page as well.

<?php
    session_start();
    ob_start();
    if( $_SERVER['SERVER_PORT'] == 80) {
        header('Location:https://'.$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"]); 
        die();
    } 

    $adminvalidated = $_SESSION['ADMINVALIDATED'];

    $_SESSION = array();

    if (ini_get("session.use_cookies")) {
        $params = session_get_cookie_params();
        setcookie(session_name(), '', time() - 42000,
            $params["path"], $params["domain"],
            $params["secure"], $params["httponly"]
        );
    }

    session_regenerate_id(true);
    session_destroy();
    session_start();

    $_SESSION['ADMINVALIDATED'] = $adminvalidated;

    echo $_SESSION['ADMINVALIDATED'];

/*
    header("Location: ../a.php");
    exit;*/
?>
  • 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-17T17:34:41+00:00Added an answer on May 17, 2026 at 5:34 pm

    In general it suffices to call session_regenerate_id(true) to change the session ID of the current session and invalidate the association with the previous session ID.

    If you additionally want to clear any session data except $_SESSION['ADMINVALIDATED'], just do this:

    session_regenerate_id(true);
    $_SESSION = array(
        'ADMINVALIDATED' => $_SESSION['ADMINVALIDATED']
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a total Groovy newbie. I saw the following code here . def
I've never had this problem before, I'm at a total loss. I have a
I'm a total loss. I have this function to read the Twitter Json. The
Total newbie question but this is driving me mad! I'm trying this: myInt =
I get the Total length of columns in constraint is too long. erro from
I'm a total newbie, but I was writing a little program that worked on
I'm a total amateur writing a small App to track to changes in folders.
What percentage of your total development effort do you spend on implementing and maintaining
Ok I am a total beginner with the Solaris Operating system and I need
I'm a total newbie to SVN and haven't been able to find an answer

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.