PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have always had to serialize and unserialize objects when passing them between sessions. I believe you still have to do this with php, but I may be wrong. You don't need to serialize sessions though if you use session_register and not $_SESSION to set the session vriables. session_register auto serializes that object for you. Let me know what works for you. I use objects with sessions alot and anything to help me understand it better is great.
If the object is serialized before end of script, do you still have to include the class definition in another file that uses but does not instantiate the object?
Eh, I could go home and try... The hour is 22:00, so I should really get myself home from work...
If the object is serialized before end of script, do you still have to include the class definition in another file that uses but does not instantiate the object?
Do you mean use without iinstantiating an object like this?
Or just not using the object and keeping it in the session variable? I don;t think you would have to include the class defenition if you just passed the serialized version of the object around.
class cSession {
var $userName;
var $queryStr;
}
session_start();
if (!isset($_SESSIONї'session'])) {
$_SESSIONї'session'] = new cSession;
$_SESSIONї'session']->userName = '';
$_SESSIONї'session']->queryStr = '';
if (isset($_COOKIEї'user'])) $_SESSIONї'session']->userName = $_COOKIEї'user'];
}