Reputation: 1484
i having a strange issue in sessions.. this is working in WAMP server in my local machine.. my problem is wen hosted to a server in US it's not working..
im doing like this:
session_start();
$_SESSION['test'] = 'testing login..';
in another page i'm doing:
session_start();
echo('my session value is : '.$_SESSION['test']);
but i'm getting only my session value is :
my session value is not setting..
i checked the session.save_path in cPanel of the server it says /tmp.
pls help.. thanks in advance.
Upvotes: 4
Views: 5548
Reputation: 81
if you're using siteground as your hosting you will need to enable the auto session. follow this steps
Upvotes: 1
Reputation: 1
Take a look at the way you created the file.
If you used auto language detection features, or something similar to create your file, then try creating a new PHP file. Copy your code and try again.
Upvotes: 0
Reputation: 41
The php opening tag must be written at first line of a php file. This method help me to solve this problem.
Upvotes: 1
Reputation: 1484
thanks for all the help.
my issue was security permission in /tmp folder. once it rectified it's working.
mean time dont use only numeric for SESSION ids, (Eg. $_SESSION['12345']) because in linux hosting its not taking the numeric only index and skipping that. (so use $_SESSION['ACS12345'])..
Upvotes: 0
Reputation: 14235
Check the permissions on your session.save_path
. This location will need to be writable by the Apache/httpd user.
Also check to see if you session.save_path
contains any sess_
prefixed files.
Upvotes: 0
Reputation: 13436
Maybe your script dies because session_start
fails with "headers already sent" ? This could happen, for example, if your test machine and production server don't encode new lines the same way...
The errors are probably not displayed on your production server, try something like that :
ini_set('display_errors', 1);
session_start();
and see if you get something useful.
Upvotes: 2