Re: Issue with the casting of a SESSION variable



On Oct 29, 4:00 pm, AndreH <aha...@xxxxxxxxx> wrote:
Good day,

I have the a bit of an issue with retrieving an object from php's
session.

I set a session variable "user" from the class User as follows:
$user = new User();
// ... do some stuff to $user
$_SESSION['user'] = serialize($user);

And try to retrieve the variable again later:
$user=(User)unserialize($_SESSION['user']);

But the last statement throws this error:
Parse error:  syntax error, unexpected T_STRING in ...

Google did not produce any useful solutions to this problem; Other
than syntax issues, but I'm 100% sure it is not an earlier syntax
issue. The problem lies in the casting of session object.

Any help would be appreciated.

Regards,
Andre

Hello Andre.

You are trying (type-casting) while retrieving the details from
session to the variable.
There is no such type "User".
and also no need to add that.
Try without "(User)".
.



Relevant Pages

  • Issue with the casting of a SESSION variable
    ... I have the a bit of an issue with retrieving an object from php's ... I set a session variable "user" from the class User as follows: ... syntax error, unexpected T_STRING in ... ... The problem lies in the casting of session object. ...
    (comp.lang.php)
  • Re: Session object gone!
    ... Are you sure you're retrieving any data? ... If you retrive Nothing, and store ... it in Session, you will get the result you've described. ... > When I return to the calling routine my Session object is gone!! ...
    (microsoft.public.dotnet.framework.aspnet)
  • Idle time in a T.S. session - how to get it?
    ... allow for the idle time for a session to be retrieved. ... Terminal Services Manager is capable of retrieving & displaying this ... Is there an undocumented information class that can be used to obtain this ... Chuck Chopp ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Delay in IMAPIAdviseSink::onNotify
    ... Do you share the session by calling MAPILogonEx or by retrieving ... Did you try to cause an RPC by retrieving PT_TEST_LINE_SPEED property from ... Do you mean "delay", ie your OnNotify method gets called some time after ... So that I have some question: Is it stupid to combine MAPI calls and OOM ...
    (microsoft.public.win32.programmer.messaging)
  • Re: Session object gone!
    ... > Are you sure you're retrieving any data? ... If you retrive Nothing, and store ... > it in Session, you will get the result you've described. ... >> When I return to the calling routine my Session object is gone!! ...
    (microsoft.public.dotnet.framework.aspnet)