Cep Posted January 8, 2008 Share Posted January 8, 2008 Hello, I was just wondering if it is possible to instantiate an object and then pass that object to a session? The reason I ask is because I instantiate an object on my script and then need too (at some point in my script) redirect back on itself (kind of like a reload). Doing this of course means I lose my object and instantiate a new one but I was wondering if I could pass it back in a session? Cheers Quote Link to comment https://forums.phpfreaks.com/topic/85008-solved-can-i-pass-an-object-to-a-session/ Share on other sites More sharing options...
rajivgonsalves Posted January 8, 2008 Share Posted January 8, 2008 Yes you can just like any other variable just keep in mind that you will have to include the class definition before session_start() or you'll get a "__INcomplete object" something error Quote Link to comment https://forums.phpfreaks.com/topic/85008-solved-can-i-pass-an-object-to-a-session/#findComment-433474 Share on other sites More sharing options...
Cep Posted January 8, 2008 Author Share Posted January 8, 2008 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/85008-solved-can-i-pass-an-object-to-a-session/#findComment-433487 Share on other sites More sharing options...
Highlander Posted January 10, 2008 Share Posted January 10, 2008 Just a tought: Is it not better to serialize the object? Quote Link to comment https://forums.phpfreaks.com/topic/85008-solved-can-i-pass-an-object-to-a-session/#findComment-435439 Share on other sites More sharing options...
rajivgonsalves Posted January 10, 2008 Share Posted January 10, 2008 well session data itself is stored in serialized form on the server... so it does not make sense Quote Link to comment https://forums.phpfreaks.com/topic/85008-solved-can-i-pass-an-object-to-a-session/#findComment-435461 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.