This is my below code
first.php
class Session
{
function __construct()
{
session_start();
}
function start()
{
$_SESSION['id'] = "1";
}
}
second.php
require "first.php";
$session = new Session();
$session->start();
echo "Session Id ".$_SESSION['id'];
It gives me an error that _SESSION not defined So i have to define session_start in start function and then it worked but i want to use it in constructor!!