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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:20:21+00:00 2026-06-18T06:20:21+00:00

When a user logs in to my system, I have a session variable $_SESSION[‘logged_in’]

  • 0

When a user logs in to my system, I have a session variable $_SESSION['logged_in'] = 1; and then on each page I check the variable to see if the user is logged in or not, which works okay:

session_start();
if (!$_SESSION['logged_in']) {
   header("location: https://mydomain.com/cpanel/login.php");
   exit();
}

But now, for ease of maintenance, I want to add this session checker to an include file and include it at the top of every secure page. However, each time I log in it fails.

This is what is in the include file:

// start session
session_start();

// check login session
if (!$_SESSION['logged_in']) {
   header("location: https://mydomain.com/cpanel/login.php");
   exit();
}

And this is what I have added to the header of each page:

// load authentication file
include "../includes/authentication/check.php";

But it appears that the $_SESSION is empty, even though I am definitely logged in. I tried removing the session_start(); from the include file as I thought that might be reetting it somehow – but that wasn’t it.

Have any of you guys got a clue as to what is going wrong here?

  • 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-18T06:20:22+00:00Added an answer on June 18, 2026 at 6:20 am

    use include_once because with include every time include session_start(); become run I Think Problem is this

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

Sidebar

Related Questions

I want to create a simple login system where the user logs in, then
I have a facebook app and a user logs in and uses it. Simple.
I have a pop-up window a user logs into, once they are logged in
I have a website and when the user logs in they can click on
Hai I have developed a standalone application in which when an user logs in,
We have a jquery/php/mysql system that allows a user to log in and review
Basically I have a Login window which should close once the user logs in
I want to have a user profile system in an app; this app has
I have the following steps in my webpage 1) User Logs in and I
I have a session scoped class that contains an object to manage user statistics.

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.