Hey. I have some php scripts. In one of them, I have session_start () code, and when I have session_start () in another script again, I get a notification:
Note: the session is already running ...
This is logical. But when I delete it, I get an error / notification message:
Note: Undefined variable: _SESSION
Why? And how do I fix this? Scripts work fine when I have session_start () two places in the script (just notice a little), but it doesn't work at all when I don't have two session_start ().
The only solution that has
error_reporting(E_ALL ^ E_NOTICE);
in my script? And is this bad practice just ignoring notifications?
Edit:
Parts of my code:
try {
$STH = DB::prepare ( "UPDATE users SET DJ_name=?, DJ_showname=? WHERE id=?" );
$STH->execute(array($_POST['DJ_name'], $_POST['DJ_showname'], $_SESSION['userid']));
pre_dump($_SESSION);
$_SESSION['DJ_name'] = $_POST['DJ_name'];
$_SESSION['DJ_showname'] = $_POST['DJ_showname'];
}
Conclusion:
Note: Undefined: _SESSION variable in D: ..... \ main.php on line 19
: Undefined: _SESSION D:.....\main.php 21
NULL
pre_dump:
function pre_dump($var)
{
echo '<pre>';
var_dump($var);
echo '</pre>';
}