PHP & MYSQL => session object using db link resource
Hi,
I have a small web application that allows a user to login.
The user is a class object and has some methods like ->login($dblnk), -> ....
For these methods, it uses a resource variable that is the link to the database so it can perform some queries on it.
I want to store the instance of the user class in a $_SESSION['user'] variable but since session variables are not allowed to hold resources, it doesn't work and I get an error that indicates the resource is an invalid mysql resource.
I tried to work around this by not holding the resource variable in the class anymore and by passing it each time to the methods respectivly. But alas, I always get this same error.
Is there some way around this or is it just completely impossible to have methods that want to perform queries? I know that it works if I don't hold the class instance in a $_SESSION variable but then I have to recreate the instance every time.
Maybe I can write some function external to the class (so it's no longer in the $_session) that handles all queries and is called from the user class but that means quit a lot of work.
So any advice or suggestions are welcome.
regards,
Lieven
|