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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:24:21+00:00 2026-06-09T12:24:21+00:00

I have 2 pages and one class, index.php, loggedin.php and userclass.php. ** Index.php **

  • 0

I have 2 pages and one class, index.php, loggedin.php and userclass.php.

**

Index.php

**

require 'userclass.php';
$user = new User();


if($user->loggedin = true){
    header("location: loggedin.php");
    die();
}   

**

loggedin.php

**

require 'userclass.php';
$user = new User();

if($user->loggedin = false){
    header("location:index.php");
    die();
}


if(isset($_POST['logout'])){
    $user->logout();
    header("location:index.php");
}

**

Userclass.php

**

public $loggedin = false;


public function logout(){
    session_destroy();
    $this->loggedin = false;
    return $this->loggedin;
}

I’m unable to logout or visit the index page without being redirected to loggedin.php.
I have a feeling it may be something to do with my scope of the logged in variable, or where it is being used?
Sorry I’m new to OO php and would appreciate any help.
Thanks

p.s. some other irrelevant functions were left out however if you think they may be relevant I’ll post them too.

  • 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-09T12:24:23+00:00Added an answer on June 9, 2026 at 12:24 pm

    You need to use two equal signs to do a comparison, otherwise you’re doing an assignment:

    if($user->loggedin == true){
    
    ....
    
    if($user->loggedin == false){
    

    The way you have it written, you’re setting loggedin equal to true every time.

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

Sidebar

Related Questions

In the pages so far, I have had used one connection class and one
I have multiple datepickers in one page. I user class name to set the
I have two pages, one that edits user information, and one that edits information
The setup: I have a standard .php file (index.php) that contains two includes, one
So I have two php classes, one is a class, one uses the other,
I have a WordPress site which have 4 pages with one page is a
I have two pages that inherit from one master page, First.aspx or second.aspx. Navigation
I have two pages. First one we open with $_POST variables in its url,
I have a solution with 3 projects.One of UI (contains web pages) and one
I'm trying to build a portal in which i have two pages , one

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.