Session class ideas?
Posted: Sat May 13, 2006 7:56 pm
I'm in the process of designing a generic session class.
I'm stuck between using built in functionality or going homemade all the way...
Before I can ultimately decide which is the best solution, I need some advice...
1) $_SESSION super global - When I assign scalars, objects, etc to session variables, do they get persisted/restored as the builtin functions are called?
What I mean is...when you create a new session, store values in the $_SESSION global and persist those changes to a medium...and then have another script start up, restore the $_SESSION global, does the array restore exactly to how it was before?
Thats kind of cool if it does work that way...
Also...how do I control how the session magic cookie is stored?
What I mean by this is, sessions are linked with browser instances in 2 ways:
1) Client side cookie
2) SESSION ID persisted through site via $_GET
I like the idea of using $_GET as it's gaurnateed to work on most number of browsers, incase cookies are off...but that also makes the sessions truely temporary...whereas cookies can be set for given periods...which is nice also...
How does the PHP session management functions help you deal with this?
I suppose you could use one over the other based on a config setting???
I want to wrap this session management functionality into a class and use generic accessor/mutator for $_SESSION data...
Any suggestions on design? I have a idea, but i'm open to suggestions?
Arborint, seeing how your the resident design pattern geek...can you think of any which would help or benefit my design any?
I'm thinking singleton would be a good start as it doesn't make sense to have more than one instance? At least at first though anyways...
I'll be honest I haven't spent alot of time thinking about a solid OOP design, at most 15 minutes
so if I sound lazy it's likely because I am 
Ideas, suggestions, etc...???
I'm stuck between using built in functionality or going homemade all the way...
Before I can ultimately decide which is the best solution, I need some advice...
1) $_SESSION super global - When I assign scalars, objects, etc to session variables, do they get persisted/restored as the builtin functions are called?
What I mean is...when you create a new session, store values in the $_SESSION global and persist those changes to a medium...and then have another script start up, restore the $_SESSION global, does the array restore exactly to how it was before?
Thats kind of cool if it does work that way...
Also...how do I control how the session magic cookie is stored?
What I mean by this is, sessions are linked with browser instances in 2 ways:
1) Client side cookie
2) SESSION ID persisted through site via $_GET
I like the idea of using $_GET as it's gaurnateed to work on most number of browsers, incase cookies are off...but that also makes the sessions truely temporary...whereas cookies can be set for given periods...which is nice also...
How does the PHP session management functions help you deal with this?
I suppose you could use one over the other based on a config setting???
I want to wrap this session management functionality into a class and use generic accessor/mutator for $_SESSION data...
Any suggestions on design? I have a idea, but i'm open to suggestions?
Arborint, seeing how your the resident design pattern geek...can you think of any which would help or benefit my design any?
I'm thinking singleton would be a good start as it doesn't make sense to have more than one instance? At least at first though anyways...
I'll be honest I haven't spent alot of time thinking about a solid OOP design, at most 15 minutes
Ideas, suggestions, etc...???