i have a simplet session class (below):
class Session{
public static function init(){
@session_start();
}
public static function set($key, $value){
$_SESSION[$key] = $value;
}
public static function get($key){
if (isset($_SESSION[$key])) {
return $_SESSION[$key];
} else if(empty($key)){
return $_SESSION;
}
}
public static function destroy(){
session_destroy();
}
}
To set a single session value i use
Session::set(Name, value);
To set a multiple session value i use
Session::set(Name, array(name, value....));
Then to simply retrieve the session i require i use:
Session::get(Name);
Now my problem is that when i can set multi dimension values, i cannot actually get them with the current get function above. SO how can i re-structure my get($key) so that it not only returns a single request but also any request
Session::set('joe', 'bloggs');
Session::set('beth', array('age'=>'21','height'=>'5.5ft'));
So for instance again I get a single session value EG Joe:
Session::get('joe');
Then if i want to get beth's details i can assign the session value to a var and then access the inner details like so:
$age = Session::get('beth');
$age['age']
But would it be possible to reconstruct my get method so i can do:
Session::get('beth','age');
Or would it be best to stick to what i am currently doing.
Thanks