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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:18:38+00:00 2026-06-02T23:18:38+00:00

I do the following to set my session, this works because the echo appears.

  • 0

I do the following to set my session, this works because the echo appears. but when I go to the next page or another the session is not there? what am I doing wrong?

$session_start();

if ($username==$dbusername&&$password==$dbpassword)
    {
        echo"<b>Login Successful</b><br><a href='systemadmin.html'><br>Click here to access the <strong>System Admin Page</strong></a>";
        $_session['username']=$dbusername;
        if($username == "admin")
        {
            $_session['admin'] = true;
        }

I am trying to get the following to work with these sessions:

<?php
session_start();
if($_session['admin'] == true)
{
// do nothing
}else{
    header( 'Location: home.html' ) ;
}

?>

Update:

the uppercase sessions work but now the sessions arent destroying when i use the logout.php

<?php

session_start();

session_destroy();

header("location: home.html");

?>
  • 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-02T23:18:40+00:00Added an answer on June 2, 2026 at 11:18 pm

    $_session should be => $_SESSION.

    http://php.net/manual/en/reserved.variables.session.php

    The first works because you are setting a ‘normal’ variable (which is available for the request).

    UPDATE

    To destroy the session:

    <?php
    // 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();
    ?>
    

    http://php.net/manual/en/function.session-destroy.php#example-4368

    Additionaly you should always use exit(); after you do a redirect to prevent further execution of the script.

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

Sidebar

Related Questions

This script works online but not offline via WAMP... function current_user() { static $current_user;
Following the instructions in this helpful guide , I've been attempting to set up
I have implemented the following set up (after being requested): slideshow of images changing,
using the following set of rules and style declarations .tableRow.even, .tableRowNS.even, .odd { background-color:
I have the following set of data: ID | CREATED | USER -------------------------- 1
I am attempting to use java scanner with the following set of delimiters &
I'm trying to map a Dictionary containing Lists. I have the following set of
I'm using log4Net for my logging. I also have the following set... <log4net debug=true>
Consider following script: SET LANGUAGE 'German' GO SET DATEFIRST 1 GO DECLARE @FullDate DATETIME
I am using following storedprocedure set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO Alter PROCEDURE

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.