Can't set User- and MandatoryObject in a Session

Notice: This thread is very old.
thundervoice
Member | 10
+
0
-

I've tried to set in the UsersPresenter set the Session Object

$section = $this->session->getSection('user');
$section->user = "admin";

I like to set an Object that comes from the Database in the UserModel in a Session with:

Object that i need save in the Session for example:
$user->user_id
$user->user_name
$user->mandator_id
$user->mandator_name
etc.

$session->user = $user;

It doesn't Works this way.

Can you help me please?

Last edited by thundervoice (2016-03-08 17:16)

David Matějka
Moderator | 6445
+
0
-

What do you mean by “It doesn't Works this way.”?

Does it throw some error? or the user key is empty in a next request?

thundervoice
Member | 10
+
0
-

Yes, if i put out the $session throw it is empty with one Parameter:

$this->sendJson($session);
{warnOnUndefined:false}

I don't understand how i can set Parameters in the $session Object. In Simple PHP something like this:

$_SESSION['user_name'] = "admin";
$_SESSION['user_id'] = 12345;
etc.

This i need from the UserObject in Database.

Last edited by thundervoice (2016-03-08 17:27)

David Matějka
Moderator | 6445
+
0
-

you cannot send Session object this way, try this instead:

$this->sendJson(iterator_to_array($session));
thundervoice
Member | 10
+
0
-

Ohhhh… I've waste hours :)

Thx it works now.