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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:48:28+00:00 2026-06-08T15:48:28+00:00

<?php require_once(‘./includes/connection.php’); ?> <?php require_once(‘./includes/sql_func.php’);?> <?php if(isset($_POST[‘submit’])) { $isValid = verify_account($_POST[‘username’],$_POST[‘password’]); if($isValid){ session_name($_POST[‘username’]); session_start();

  • 0
<?php require_once('./includes/connection.php'); ?>
<?php require_once('./includes/sql_func.php');?>
<?php 
    if(isset($_POST['submit']))
    {
        $isValid = verify_account($_POST['username'],$_POST['password']);
        if($isValid){
            session_name($_POST['username']);
            session_start();
            $_SESSION['isLoggedIn'] = true;
            session_write_close();
            redirect_to("user_panel.php");

        }else{
            echo "Invalid Username and password";
        }
    }
?>
<?php require_once('./includes/header.php');?>

Assuming that the user has entered a valid username and password it will create a session variable and will store different values in the session array. but how come when I redirect a user to another page the

<?php require_once('./includes/connection.php'); ?>
<?php require_once('./includes/sql_func.php');?>
<?php 
    session_start();
?>
<?php require_once('./includes/header.php');?>
    <?php 
        if(isset($_SESSION['isLoggedIn'])){
            echo "Hello User";
        }
    ?>

<?php require_once('./includes/footer.php');?>

This Line on the code above

 isset($_SESSION['isLoggedIn'])

is not being read as true?

  • 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-08T15:48:29+00:00Added an answer on June 8, 2026 at 3:48 pm

    You are creating a session with session_name($_POST['username']); in your first page, then starting the session without a name in the second page. This essentially means that the second page is using a different session to the first.

    Have a look at the PHP manual for session_name for more information, but the easiest fix is probably to drop that line altogether.

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

Sidebar

Related Questions

<?php require_once 'swift-mailer/lib/swift_required.php'; if (isset($_POST['submit'])) { //File upload // Where the file is going
<?php require_once includes/db_data_inc.php; try { /* In this way I get a db connection
from my logout.php : <?php require_once(includes/session.php); ?> <?php require_once(includes/functions.php); ?> <?php if ( isset(
<?php require_once('inc/dbc1.php'); $pdo = new PDO('mysql:host=###;dbname=#####', $username, $password); $pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); $sth =
PHP PDO Singleton Class: <?php require_once('app/config.php'); // Require constants HOST, DATABASE, USER, PASSWORD /*
Came across this code: <?php require_once 'HTTP/Session/Container/DB.php'; $s = new HTTP_Session_Container_DB('mysql://user:password@localhost/db'); ini_get('session.auto_start') or session_start();
I have an index.php file that has 3 includes <?php require_once('mod.php'); $mod = new
<?php #require_once('inc/dbc1.php'); $dsn = 'mysql:dbname=dbname;host=somehost; $user = 'someuser'; $password = 'SomePass'; try { $dbh
I have a php page (horses.php) that includes: <?php require_once('send_email.php');?> What happens is I
This is my general php page: <?php require_once('includes.php'); require_once('cms.class.php'); ..... rest of the page

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.