I got a big problem when I tryed to work directly with session...
/* session_start(); //already tried */
if (isset($_SESSION) == false)
{
session_start();
$_SESSION['PDO'] = new dataBase();
$_SESSION['Debug'] = 'Inside the isset';
}
else
{
$_SESSION['Debug'] = 'Outside the isset';
}
EDIT:
session_start();
if (!isset($_SESSION['PDO'])) // the session is new
{
$dbObject = new dataBase(); // store the data into the session
$_SESSION['PDO'] = $dbObject;
echo 'I created a session and stored some data into it';
}
else
{ // there is data into the session
var_export($_SESSION);
echo 'I have some data in the session';
}
The output is always "I created a session and stored some data into it"
I begin to think that the problem may come from my class
class dataBase
{
var $connLink;
var $SERVERNAME = "127.0.0.1";
var $PORT = "3388";
var $USERNAME = "root";
var $PASSWORD = "";
function __construct()
{
try
{
$this->connLink = new PDO("mysql:host=$this->SERVERNAME;port=$this->PORT;dbname=mydb;charset=utf8", $this->USERNAME, $this->PASSWORD);
$this->connLink->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e)
{
echo 'Echec lors de la connexion : ' . $e->getMessage();
}
}
}
Thanks !