I have a page on my local computer with a script that interacts with a remote server. For every request, it gets a different PHPSESSID value. Does this have something to do with the page not being associated with a domain? Is there a way to solve this, perhaps maybe manually setting the PHPSESSID or something in php.ini
?
Look, I don't know where the downvotes are coming from or the request to close, either. Just seems like trolling to me. This is not a coding error. This is a server error. Code will do nothing. Seriously, as plain and standard as you can be, like:
$.post('http://example.com/server.php',{'stuff':'data'},function(){
});
// PHPSESSID is 545ty789gh78rhr
Then, when I call it again:
$.post('http://example.com/server.php',{'stuff2':'data'},function(){
});
// PHPSESSID is fnunurhf894fh
And then, on the php page:
session_start();
if(isset($_POST['stuff']) $_SESSION['variable'] = '123';
if(isset($_POST['stuff2']) echo $_SESSION['variable']; // Returns nothing, as the PHPSESSID cookie value has changed
Thus, I'm thinking it's either in php.ini
or has something to do with how php handles session cookies with no http domain (just a local script accessing the server). I'm wondering if there's something in php.ini
that would solve it or perhaps if there's a way to manually set the PHPSESSID's (if there's no way through php.ini
).