Re: Issue with the casting of a SESSION variable
- From: Suhas Dhoke <suhasdhoke@xxxxxxxxx>
- Date: Wed, 29 Oct 2008 04:08:38 -0700 (PDT)
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)".
.
- Follow-Ups:
- Re: Issue with the casting of a SESSION variable
- From: AndreH
- Re: Issue with the casting of a SESSION variable
- References:
- Issue with the casting of a SESSION variable
- From: AndreH
- Issue with the casting of a SESSION variable
- Prev by Date: Issue with the casting of a SESSION variable
- Next by Date: Re: Problem:
- Previous by thread: Issue with the casting of a SESSION variable
- Next by thread: Re: Issue with the casting of a SESSION variable
- Index(es):
Relevant Pages
|