mfyvie
06-30-2007, 05:03 PM
I'm trying to store and reuse a value that should be valid for the entire session, whether a logged-in user or a guest. This value would then be available for use on any page loaded during that session.
Could someone perhaps point me to the most efficient way to do this? I started looking at the vB_Session class which seemed to have some promising methods, but then I realised that these are hard-coded for the existing fields in the session table.
Should I simply put something in the datastore? But if I put something in the datastore how will I be sure that it cleans out after the session expires? On re-reading the article about the datastore and taking a look at it, it appears that it isn't really designed for storing data associated with a session.
I apologise if this sounds like I'm asking too many questions - but I have been reading through the vB code documentation and various tutorials all day. This is sort of along the lines of what I want:
at global_start:
if (!isset($userinfo['foo'])) {
$userinfo['foo'] = "Our value to remain for the entire session";
// now we need to save it somehow so when the next page
// is loaded it is still here, and this conditional doesn't execute again
}Any help would be greatly appreciated! (this question is unrelated to my other thread about adding a field in the admincp by the way)
Could someone perhaps point me to the most efficient way to do this? I started looking at the vB_Session class which seemed to have some promising methods, but then I realised that these are hard-coded for the existing fields in the session table.
Should I simply put something in the datastore? But if I put something in the datastore how will I be sure that it cleans out after the session expires? On re-reading the article about the datastore and taking a look at it, it appears that it isn't really designed for storing data associated with a session.
I apologise if this sounds like I'm asking too many questions - but I have been reading through the vB code documentation and various tutorials all day. This is sort of along the lines of what I want:
at global_start:
if (!isset($userinfo['foo'])) {
$userinfo['foo'] = "Our value to remain for the entire session";
// now we need to save it somehow so when the next page
// is loaded it is still here, and this conditional doesn't execute again
}Any help would be greatly appreciated! (this question is unrelated to my other thread about adding a field in the admincp by the way)