I was working on a webpage and it was working all fine until I tried to send it to my paid web hosting service. It is the first time I try to use SESSIONs in this new remote server.
My application stopped working and I thought there was something wrong with the API I use. After a long attempt to fix this problem, I tried to var_dump() the SESSION array. It was empty. But only with AJAX requests. If I access it directly via browser it works great, but with AJAX it fails. I turned sessions on with the session_start() function.
So I bet it's some problem with my PHP.ini or any configuration in the Apache running on my remote web server.
Do you guys know how to solve it? Can it be a problem with the script I am using to send the requests? It works fine on localhost
#edit
testing.php
session_start();
echo session_id();
$_SESSION['testing'] = 'some_stuff';
server.php
session_start();
echo session_id();
echo 'testing is '.$_SESSION['testing'];
Related
I use ngrok to tunnel localhost to a web address
./ngrok http 80
I use only custom PHP code. Last time I tested it was working ok. Now, I can't login because it seems my PHP resets the data stored in session every 5 or so requests.
When I say reset I mean that my code calls session_id() does not get it and resets that valuable session data including internal captcha code! At the end captcha comparison fails!
Everything works fine at localhost though!
I reset session.cookie_domain with ini_set() setting the ngrok url.
Any ideas?
At last I found it: for a address xxx.ngrok.io just set php session cookie for domain .xxx.ngrok.io and do not include http.
Server has nginx and php on it.
When i am trying to echo file_get_contents(); with any website as input - everything works fine
when i am trying to echo file_get_contents(); with url of page which is on the same server - timeout shows up.
I tried using cURL as well. It won't work, drops timeouts also.
Check your internet limitation access on your network! I have my own solved!
I have a problem in my application using SESSION array. It has been working for a couple of weeks but then suddenly stopped working (without any noticable change in code or settings). I shortened the code to this:
<?php
session_start();
var_dump($_SESSION);
$_SESSION['meh'] = 'MEH';
?>
It shows an error: 'A session has alredy been started...'. This is now my whole code in index.php, which is the only file in server's directory. After the second (third...) run the $_SESSION is still empty. Working with PHP 7.0, testing on Firefox and Opera (Cookies allowed). On local server is everything fine. Any ideas how to fix it? Somewhere in config/cache or whatever? Thanks
you may have another session_start() in your code
or
try this
from the old answer
<?php
if(!isset($_SESSION))
{
session_start();
}
?>
I've got a problem with my Session in PHP, if I refresh my page it set a new session_id each time.
I use the PHP built in server and PHP 7.1 and nothing more than that :
<?php
session_start();
echo session_id();
Each refresh give me a new Session Id. Each ? Not really in fact, if I refresh super quickly I have the same session id for 1 or 2 seconds.
I don't know where to look, my php.ini seems correct, my code too I believe.
My folder to register session is 777.
Where could I look or what test could I do ?
Edit : I don't know why but changing localhost to 127.0.0.1 in the built in server solved the issue
I don't know why but changing localhost to 127.0.0.1 in the built in server solved the issue.
I'm using a PHP script to detect of a referral URL is a proxy. This is a very simplified version but it works great.
The problem is that I'm trying to use the same script on my other web server but for reasons am not copying over the script. What I'm doing instead is using a get_file_contents.
My problem is that when I use get_file_contents it detects it as a proxy. Is there anyway around this, possibly by changing the port?
<?php $stop = file_get_contents("http://mysite.com/file.php"); echo $stop; ?>
Any help would be great, Thanks!
file_get_contents with a remote URL is very different from a local URL -- you are actually running the script on mysite.com and simply getting the output of that script on your local server. This actually sends another HTTP request to mysite.com, so the referrer for that request is different from the referrer for your original request.