i have a PHP application that uses $_SESSION global to manage data inside the app. However i have a little problem when trying to update the values of $_SESSION, this is what i have done so far:
- do stuff
- unset($_SESSION['var'])
- do stuff
- $_SESSION['var']=newValue();
I call the php using $.post() like this:
$('#id').click(function(){
    $.post("page.php", function(data){
        //do stuff
        window.location = "goto.php";
    })
})
goto.php grabs the content from $_SESSION['var'] and construct a new html.
But, when the webpage goes to goto.php it loads the html that was created using the last version of $_SESSION['var']. Note that if i refresh the webpage, then it load the new content created with the new $_SESSION['var'].
Also this is not a regular behavior, sometimes it loads right without the page reload.
What i'm i doing so fundamentally wrong in here?
 
     
    