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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:00:32+00:00 2026-05-25T06:00:32+00:00

I have an index.php page that creates a new Login class (login class does

  • 0

I have an index.php page that creates a new Login class (login class does all the handling of data,creating session, redirecting, etc)

index.php I create a new login class

  require_once('login.class.php');  
  $login = new Login;

Login constructor looks like this

public function __construct(){
    // Start session and open a database connection 
    session_start();
    $this->connectToDB();
}

if the user logs in successfully, I redirect him to securePage.php.

if I do the following on the securePage.php

$test = $_SESSION ['usrData'];
var_export($test->getFirstName());
var_export($test->getLastName());
var_export($test->isAuthorized());

it displays the following error

Fatal error: Call to a member function getFirstName() on a non-object
in /login/securePage.php on line
17

When, however, I put

$login = new Login;

in front of

var_export($test->getFirstName());
var_export($test->getLastName());
var_export($test->isAuthorized());

It works! I dont’ know what gives and if I am doing something wrong because even when I put

session_start();

instead of

$login = new Login;

but it still gives me the error

Fatal error: Call to a member function getFirstName() on a non-object
in /login/securePage.php on line
16

  • 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-25T06:00:33+00:00Added an answer on May 25, 2026 at 6:00 am

    I think it has to do with the variable name. If I am not wrong, in your securePage.php, here is the code:

    $login = $_SESSION ['usrData'];
    var_export($login);
    var_export($test->getFirstName());
    

    It should be:

    $login = $_SESSION ['usrData'];
    var_export($login);
    var_export($login->getFirstName());
    

    Hope it helps.

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

Sidebar

Related Questions

I have a function that I use on index.php page and I would like
I have the following scenario. I have a index.php page with the following JQuery
I have an index page index.php , and when the user clicks on a
I have a page index.php where i have a link called add_users.php. In add_users.php,
I have a index.php file that will include several external files: content/templates/id1/template.php content/templates/id2/template.php content/templates/id3/template.php
Let's say we have index.php and it is stored in /home/user/public/www and index.php calls
I have an index.php file which has to process many different file types. How
I have a pretty complicated index.php now, and I would like to only run
i have two files:(localhost/template/) index.php template.php each time when i create an article(an article
I have a folder structure like this: /articles .index.php .second.php .third.php .fourth.php If I'm

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.