I'm having trouble with session and header. First of all, they are both working on my local development computer. But after I published the website, they don't work there.
The first problem is about storing session data. I tried everything.
- I wrote
session_start()
at the top of the page. - Checked if the folder is writable with
is_writable(session_save_path())
method. Which returns true.
But still not working.
Second is about header("location: ")
. It works too on my localhost but not working on the server that I published the website.
What am I missing?
For example, at index.php, those lines don't work.
<?php
session_start();
if (empty($_SESSION['counter'])) {
$_SESSION['counter'] = 0;
}
echo $_SESSION['counter'] ++;
?>
When I refresh the page, it doesn't increment the value.