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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:01:55+00:00 2026-05-20T17:01:55+00:00

Hey, ive got a mysterious problem at the moment… i have a login service

  • 0

Hey,
ive got a mysterious problem at the moment…
i have a login service on my website.
I use Doctrine as ORM.
When the user entered the right combination for username and password i try to store the retrieved user object in my session for later purpose.

$user = new models\User;
$user = $em->getRepository('models\User')->findOneBy(array(
           'username' => $this->input->post('username'),
           'password' => hash("sha512", $this->input->post('password'))
           ));

   if($user != NULL) {
        session_start();
        $_SESSION['user'] = $user;
    redirect('user');
    }

thats a part from my login

       /**
         * @ManyToOne(targetEntity="Country")
         * @JoinColumn(name="country_id", referencedColumnName="id")
         */
        private $country;

user has different attributes like country, address etc.

so my problem is:
if the field Country is null (in the db) for the user the login works fine… but if the user is assigned to a country (country has just id and name) my system fails.
after the redirect the is no $user in $_SESSION
There is no php error or something like this.. the variable just goes away

would it maybe better just storing the id in session and load the user on every page load?

  • 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-20T17:01:56+00:00Added an answer on May 20, 2026 at 5:01 pm

    would it maybe better just storing the id in session and load the user on
    every page load?

    Sure. User data may have changed already on next page load, so you obviously need to refresh data from database, not read old data of the user from session.

    references:

    PHP: Storing 'objects' inside the $_SESSION

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

Sidebar

Related Questions

Hey all! Ive got timezone troubles. I have a time stamp of 2010-07-26 23:35:03
Hey guys ive got the following Model for Accounts require 'net/http' require 'uri' require
Hey all. Ive got a headache trying to get my head around this. I
Hey Friends I've got another xsl/xpath problem. Sure a beginners problem, but I'm thinking
Hey folks, I've got this rather clumbsy piece of xslt which I use to
Hey, I've got what has become an extremely frustrating problem with $_Post variables. I'll
Hey there, I have read the few posts here on when/how to use the
Hey. I've got a login form with post as method. The action goes to
hey ive got a working php script, and as far as i can tell
hey guys, ive got one big database table report. The way i want, split

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.