3

I'm using PHP with XAMPP. My PHP files work, but if I call session_start() in anywhere in the script and run it, writing "Waiting for localhost" at the page title, and page is loading forever, just shows a blank page and keeps loading.

I've also tried enabling the errors and no errors shown.

This runs:

<?php
echo "test";
?>

This doesn't run (blank page and the page is loading forever)

<?php
session_start();
echo "test";
?>

EDIT: Due to Fred's suggestion, I'm posting my session information from phpinfo() result:

Session Support  enabled  
Registered save handlers  files user  
Registered serializer handlers  php php_binary wddx  

session.auto_start Off Off 
session.cache_expire 180 180 
session.cache_limiter nocache nocache 
session.cookie_domain no value no value 
session.cookie_httponly Off Off 
session.cookie_lifetime 0 0 
session.cookie_path / / 
session.cookie_secure Off Off 
session.entropy_file no value no value 
session.entropy_length 0 0 
session.gc_divisor 1000 1000 
session.gc_maxlifetime 1440 1440 
session.gc_probability 1 1 
session.hash_bits_per_character 5 5 
session.hash_function 0 0 
session.name PHPSESSID PHPSESSID 
session.referer_check no value no value 
session.save_handler files files 
session.save_path C:\xampp2\tmp C:\xampp2\tmp 
session.serialize_handler php php 
session.upload_progress.cleanup On On 
session.upload_progress.enabled On On 
session.upload_progress.freq 1% 1% 
session.upload_progress.min_freq 1 1 
session.upload_progress.name PHP_SESSION_UPLOAD_PROGRESS PHP_SESSION_UPLOAD_PROGRESS 
session.upload_progress.prefix upload_progress_ upload_progress_ 
session.use_cookies On On 
session.use_only_cookies Off Off 
session.use_trans_sid 0 0 
Aycan Yaşıt
  • 2,106
  • 4
  • 34
  • 40

2 Answers2

1

Having looked into this on my own environment it appears to be a glitch in the XAMPP software stack itself, I receive errors in my system error log indicating that the child process exited with a long status code followed by restarting. This is not a PHP related fault, rather it is a fault with the implementation in XAMPP. I have forwarded the details of the error to Bitnami which is a development member of the project and hopefully they will be able to resolve this and release an updated version, in the meantime I would recommend using wamp.

Chris Rutherfurd
  • 1,617
  • 1
  • 15
  • 32
0

I've had this problem when i run more than one page that use session_start() on a localhost at the same time.

" PHP writes its session data to a file by default. When a request is made to a PHP script that starts the session (session_start()), this session file is locked. What this means is that if your web page makes numerous requests to PHP scripts, for instance, for loading content via Ajax, each request could be locking the session and preventing the other requests from completing. " http://konrness.com/php5/how-to-prevent-blocking-php-requests/

klsx
  • 441
  • 4
  • 6
  • The file's are only locked for nanoseconds. You can have 10000 requests per second and they don't noticeably block each other. Locking happens very very very fast. – Daniel W. Feb 18 '16 at 09:55
  • http://stackoverflow.com/a/14966334/3787376 "You have the classic problem with filesystem-backed sessions. Your upload script locks the session backing file for its duration, so it's impossible to get access to the session information until it releases the lock." and "To release the session lock, call `session_write_close` at any point from your upload script. This leaves you without access to session variables until you call `session_start` again later on. You can repeat this cycle as much as you like." Here is some evidence of where locking does occur. – Edward Apr 04 '16 at 21:00