[Fixed] Uncouple ManiaConnect from PHP sessions
Posted: 28 Sep 2011, 11:47
After trying around a bit with the ManiaConnect feature, I want to make a suggestion regarding the use of PHP session.
The Problem:
In my projects, I never use PHP sessions to store any data. The reason is, that I mostly work with forum softwares (like vBulletin on mania-community.de), which bring their own session system based on the database.
Currently I am able to use an own session system by deriving the ManiaConnect\Player class and by overwriting the five methods getVariable(), setVariable(), deleteVariable(), logout() and __construct().
The constructor is the problem: I cannot call parent::__construct() to initialize the parent classes, as this would initialize the PHP session. But I still have to call the HTTPClient's constructor... (Using \Maniaplanet\WebServices\HTTPClient::__construct($username, $password); in my class' constructor works fine, but I don't really like the idea of skipping a constructor, as the code may break as soon as the Client's constructor changes.)
The Suggestion:
Introduce a new (protected) method called e.g. initSesstion(), which can be overwritten by any child class to use the own session system, without having to overwrite the constructor.
(You may think about the same for the session_destroy() call in logout().)
The Problem:
In my projects, I never use PHP sessions to store any data. The reason is, that I mostly work with forum softwares (like vBulletin on mania-community.de), which bring their own session system based on the database.
Currently I am able to use an own session system by deriving the ManiaConnect\Player class and by overwriting the five methods getVariable(), setVariable(), deleteVariable(), logout() and __construct().
The constructor is the problem: I cannot call parent::__construct() to initialize the parent classes, as this would initialize the PHP session. But I still have to call the HTTPClient's constructor... (Using \Maniaplanet\WebServices\HTTPClient::__construct($username, $password); in my class' constructor works fine, but I don't really like the idea of skipping a constructor, as the code may break as soon as the Client's constructor changes.)
The Suggestion:
Introduce a new (protected) method called e.g. initSesstion(), which can be overwritten by any child class to use the own session system, without having to overwrite the constructor.
(You may think about the same for the session_destroy() call in logout().)