We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

how to track a big object in session

I'm developing a simple strucutre but complex function websit, it has a lot of manipulations, like a web game.

so I hope to track a lot of status of the user, session is the best, but there are too many variable, so I hope to put them in an object, and use session to store it.

I tried but failed, I store the data object in session

> $userdata = new userdata(some var);
> $this->session->set("userdata", $userdata);

but when I take it out in another controller or action

> var_dump($this->session);

it displays

> object(Phalcon\Session\Adapter\Files)[47]
>   protected '_uniqueId' => null
>   protected '_started' => boolean true
>   protected '_options' => null

this means I can't use

> $userdata=$this->session->get("userdata");

to take out the data

can anyone help me?

Do a dump of $_SESSION, as that's where Phalcon stores the session data anyway.

I'd suggest not storing your information in an object. It's a pain in the butt if you want to extract/update information from an object stored in session, and there's nothing wrong with putting lots of variables in the session. You're not saving anything by putting your information in an object.



8.1k

You can make serialize of object and store it in session

well I see the difficulty, now I'm storing the big data in array instead of object, and use memchache to read and store the session data, the speed is acceptable.