Basically I just want to go to the same file I used for the header. Here is my example code:
$_SESSION['user_id'] = $login;
header("Location: index.php");
die();
That same code is in index.php. I want to just reload the page. How would I do that?
Basically I just want to go to the same file I used for the header. Here is my example code:
$_SESSION['user_id'] = $login;
header("Location: index.php");
die();
That same code is in index.php. I want to just reload the page. How would I do that?
 
    
    it s tested and work
it refresh once :
<?php
if(! isset( $_GET["refresh"] ) ) {
header( "Location: index.php?refresh=1" );
exit;
}
?>
 
    
    You're possible to redirect to the same file. But you must add some condition of when will process the redirect to prevent the non stop redirect in the same page.
  $_SESSION['user_id'] = $login;
    if(CONDITION)
    {
      header("Location: index.php");
    }
    die();
 
    
    Try this code:
 header('Location: '.$_SERVER['REQUEST_URI']);
 
    
    Cannot modify header information - headers already sent means that your code has already sent something to the browser window.  Once that happens, you can't send headers any more.  Look at your script and identify what sent something to the browser, and use your header() call before that.
 
    
    I found the solution! Thank you everyone!
The answer was this:echo "<meta http-equiv='refresh' content='0'>";
 
    
    1st : you missed to start the session .so while error thrown to browswer .once your code started out put to browser .while you trying to redirect another page . so while this error will occur .  
2nd : you need to start the session each page .
start_session();
$_SESSION['user_id'] = $login;
header("Location: index.php");
exit();
