I'm trying to learn OOP in PHP and I'm making a class with static methods.I tried the code below but the session_start(); will not work because the methods are static and no object is getting instantiated.Do you know any solution to this problem?
<?php
class Session{
public function __construct(){
session_start();
}
public static function set($data){
foreach ($data as $key => $value) {
$_SESSION[$key] = $value;
}
}
public static function get($key){
return $_SESSION[$key];
}
}
Session::set(array(
'mySessionKey' => 'mySessionValue'
));