Answer the question
In order to leave comments, you need to log in
What's the best way to do it with OOP?
There is a class in which work with sessions is going on, so here's how best to do it:
$class = new Class();
$sessionid = $class->getSession("auth_data");
$class->method($sessionid);
$class = new Class("auth_data");
$class->method();
Answer the question
In order to leave comments, you need to log in
Your implementation is not very clear. Depending on the task, you can use either way.
You can also resort to using DI containers, and the issue of creating multiple sessions can be solved by a factory method or returning an object clone.
For an example, check out the quality implementation:
pop-session
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question