Sessions don't work in PHP -
this test script:
<?php ob_start(); // or without same $session = session_start(); $path = session_save_path(); if (headers_sent()) die ("headers have been sent"); if((isset($_get["set"]))) { $_session["var"] = " - testing - "; } echo $_session["var"]; echo $session; echo $path; print_r($_session); print_r($_cookie); setcookie("cookie", "value");
$session
outputs 1
. cookies being set successfully. have phpsessid cookie set. sessions (from phpinfo) enabled. session_start()
there.
when set session variable (by setting set
parameter), session variable echoes directly $_session
array. when remove set
parameter, print_r-ing $_session
outputs empty array.
i've gone far set chmod 777 on /var/lib/php5
, , chown
-ed same user runs php. tried different domain name, defining in local /etc/hosts
, setting new virtual host it.
i found 1 answer on stackoverflow said disable register_globals
in php.ini
, don't have setting in phpinfo
output, didn't do...
i've tried changing session directory session_save_path()
, didn't work. might not have privileges on (vps) hosting.
i don't know else try?
this session section of phpinfo() output, if helps:
session 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 /dev/urandom /dev/urandom session.entropy_length 32 32 session.gc_divisor 1000 1000 session.gc_maxlifetime 1440 1440 session.gc_probability 0 0 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 /var/lib/php5 /var/lib/php5 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
solved.
it seems whole account doesn't have privileges go public_html
folder, /var/lib/php5
folder trying open "relative" folder inside public_html
. realized after turned on error_reporting
.
so after created public_html/var/lib/php5
in ftp root , made writable, sessions started working.
i don't think conventional environment, again i've had stranger things on hosting.
Comments
Post a Comment