0
votes

I've a problem with PHP sessions. This is my code:

login.php

<?php
session_start();
...
...
...
$_SESSION['id'] = $user['id'];
$_SESSION['name'] = $user['nome'];
$_SESSION['ruolo'] = $user['ruolo'];
$_SESSION['auth'] = true;

header("location: index.php"); 
exit();
...
...

index.php

<?php
session_start();
var_dump($_SESSION);
...
...
?>

result is array(0) { }

I've already seen other similar posts, but no proposed solutions are helpful to me (session_start, exit after header, etc)

Some suggestions?

1
U have cookies enabled in your browser? - DarkBee
This link might help you. stackoverflow.com/questions/17242346/… - Nilesh
Thank for your reply. I've checked everything: as you can see session_start() is in every script; I've tried also with session_write_close() and session_regenerate_id() functions, with no results; cookies was enabled in my browser; register globals is set to off; the Session superglobals is not overwritten anywhere (as you can see from the code). Have you some other suggestions? Thanks - lucag

1 Answers

0
votes

Try adding this to the top of your script:

ini_set("session.cookie_domain", ".domain.com");