It does not make sense. It works in localhost, but not on my server.
Before submitting the form, if I am var_dump() $_SESSION, it returns me the following:
array(2) { ["email"]=> string(40) "082b6eff9db5019e6a28f586a679b7f72fab27f4" ["id"]=> int(5) }
The form is as follows:
<form method='POST' action='response.php?type=add_customer'>
<input type='text' name='customer'/>
<input type='submit' value='add'/>
</form>
If I'm var_dump() $_SESSIONon response.php , I get:array(0) { }
if(!isset($_SESSION)){ session_start(); }
var_dump($_SESSION);
How is this possible?
Because it works localhost, but not on my server. Maybe this is php.ini problem? If so, then what?
EDIT (1) : changed my code to this (in response.php ):
session_start();
if(isset($_REQUEST['type'])){
switch ($_REQUEST['type']){
case 'add_customer':
var_dump($_SESSION);
break;
}
}
Still working. It retrieves an empty array.
EDIT (2): Allowed. If anyone could explain to me why this:
session_start();
var_dump($_SESSION);
print_r($_SESSION);
echo $_SESSION['id'];
I value. Because the problem was this.
source
share