1
votes

enter image description hereI am not able to set SESSION on my godaddy shared linux hosting server. I have given all permissions to /tmp, but that didn't worked. So I made a new folder /session and give write permissions. But that also didn't work. When I try to read session variable from other Files, I get empty value.

Basic codes

setting session

<?php
session_save_path('/session');
session_start(); 

print_r(session_save_path());

$_SESSION['foo']='bar'; 

// echo a little message to say it is done
echo 'Setting value of foo'.$_SESSION['foo']; 
?> 

retrieving session

  <?php
session_save_path('/session');
session_start();

print_r(session_save_path());

echo 'The value of foo is '.$_SESSION['foo']; 
?> 
2
error_reporting(E_ALL); ini_set('display_errors', '1');AbraCadaver
@AbraCadaver while using default session path , I am getting no error while setting session , but getting Notice: Undefined index: foo in /home/coachgator/public_html/test3.php , while retreiving sessiontarun14110
I think you have other issues like headers already sent before the session_start() call.AbraCadaver
@AbraCadaver how can I resolve this issue ?tarun14110
With error reporting on you see errors or in the logs. That we be a start.AbraCadaver

2 Answers

0
votes

Since you're on a shared server, you most likely won't have access to the root directory, so the path won't actually be /session. Try to get the full path of the folder. You really don't need to set the session_save_path, as it will use the default instead.

0
votes

Godaddy are some kind of gypsies,they dont help you in anything, they only want u pay more and more. But of course there is a trick,If you need to change any of that values the only thing you need is to create a file called ".user.ini" inside of public_html folder and put there all values you want to change, ex:

session.cookie_lifetime=28800
session.gc_maxlifetime=28800
session.cache_expire=28800
max_input_vars = 5000
upload_max_filesize = 900M
memory_limit = 128M
max_execution_time = 180
post_max_size = 950M
max_input_time = 180

And that's all. You can check it after using phpinfo().