When I use php header redirection all session variables are lost... Some people say that adding exit(); just after the header(\"\"); will solve the problem but it doesn\'t s
You just need to check the file permission in /var/lib/php directory give yje public permisssion to /var/lib/php/session directory.
and all done.
You aren't starting the session. In order to use session variables and have them carry across pages, you need to put
session_start();
at the top of each page before anything else.
These sessions does not always work as we expect sometimes. I had a similar problem with my website using sessions that get lost. I basically solved it by injecting the value I want to keep on the session into the hidden text field the first time the page loads. Then the second time I call the page(page submit) I simply read the value from the hidden text field and carry on with rest of my code.
That's more easier and cleaner than using sessions in this case!
Simples! make sure the page you are coming from (e.g. www.example.com) redirects to a (eg.g www.example.com/redirect.php) notice www at the beginning. If you change that from page to page, then yes things get wonky.
exit; should be placed after header redirection or session_regenerate_id(true); can be used
You need to put exit();
after your header redirection, otherwise you have just loaded two pages of content into 1 page.
Also make sure you have session_start();
at the top of all your scripts.