Is there a Symfony callback at the termination of a session?
Posted
by Rob Wilkerson
on Stack Overflow
See other posts from Stack Overflow
or by Rob Wilkerson
Published on 2010-06-15T15:32:29Z
Indexed on
2010/06/15
18:22 UTC
Read the original article
Hit count: 230
I have an application that is authenticating against an external server in a filter. In that filter, I'm trying to set a couple of session attributes on the user by using Symfony's setAttribute()
method:
$this->getContext()->getUser()->setAttribute( 'myAttribute', 'myValue' );
What I'm finding is that, if I dump $_SESSION
immediately after setting the attribute. On the other hand, if I call getAttribute( 'myAttribute' )
, I get back exactly what I put in.
All along, I've assumed that reading/writing to user attributes was synonymous with reading/writing to the session, but that seems to be an incorrect assumption. Is there a timing issue? I'm not getting any non-object errors, so it seems that the user is fully initialized.
Where is the disconnect here?
Thanks.
UPDATE
The reason this was happening is because I had some code in myUser::shutdown()
that cleared out a bunch of stuff. Because myUser
is loosely equivalent to $_SESSION (at least with respect to attributes), I assumed that the shutdown()
method would be called at the end of each session. It's not. It seems to get called at the close of each request which is why my attributes never seemed to get set.
Now, though, I'm left wondering whether there's a session closing callback. Anyone know?
© Stack Overflow or respective owner