0

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?

vels4j
  • 11,208
  • 5
  • 38
  • 63
lucag
  • 1
  • 4
    U have cookies enabled in your browser? – DarkBee Dec 27 '13 at 10:18
  • This link might help you. http://stackoverflow.com/questions/17242346/php-session-lost-after-redirect – Nilesh Dec 27 '13 at 10:28
  • 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 Dec 27 '13 at 12:05

1 Answers1

0

Try adding this to the top of your script:

ini_set("session.cookie_domain", ".domain.com");
user3095432
  • 39
  • 1
  • 9