I have a strange situation while trying to make a site work on bluehost for someone. I have built a very simple example to illustrate this. I have two files:
<?php
session_start();
$_SESSION['x'] = 'yes';
var_dump($_SESSION);
and:
<?php
session_start();
var_dump($_SESSION);
now the problem is, when I call the first file I get this: array(1) { ["x"]=> string(3) "yes" }
but if immediately after that I call the second file I get this: array(0) { }
So, the session doesn't seem to persist between calls. Any idea what might cause this?
the phpinfo session settings are:
Session Support enabled
Registered save handlers files user
Registered serializer handlers php php_binary wddx
Directive Local Value Master Value
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 4 4
session.hash_function 0 0
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path /tmp /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 On On
session.use_trans_sid 0 0
It might help others... The hosting provider is BlueHost and after a few emails back and forth, in which they blamed the development, they admitted it might be because of Varnish, which they have enabled by default with Wordpress optimized packages. https://my.bluehost.com/cgi/help/turn_varnish_off
After turning it off, the session and cookies seem to work