Storing a Doctrine object in $ _SESSION

Hey, At the moment, I have a mysterious problem ... I have a login service on my site. I use the Doctrine as an ORM. When the user entered the correct combination for the username and password, I will try to save the extracted user object in my session for further purposes.

$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');
    }

this is part of my entry

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

The user has different attributes, such as country, address, etc.

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

, ?

+3
2

, ?

. , , , , .

:

PHP: "" $_SESSION

+5
0

All Articles