I have one index.php , one.php file.
In one.php i have starting the session and setting the session var:
session_start();
if(isset($_GET['user'])){
$_SESSION['user'] = $_GET['user'];
}
function getUsername(){
return $_SESSION['user'];
}
Im including one.php in index.php after im calling the function getUsername()
im not starting session in index.php
include_once('one.php');
echo getUsername();
But im not getting the session in index.php. Why ? im passing the the variable as
index.php?user=newuser .
is it not possible to get the session in all pages with out starting session . is it any possible method to get a global variable from any where, if i set it once..?
index.phpafter the opening<?phptag...ini_set('display_errors', 'On'); error_reporting(E_ALL);. FYI, you must callsession_start()before any output (HTML, whitespace, etc) is sent to the browser.