mrj Posted October 12, 2020 Posted October 12, 2020 Hi,I am using following function to get online users count. But it appears that there is no permission for reading content of that dir. Can you help me please?Server: tommy function onlineUsers() { $i = 0; $path = session_save_path(); if (trim($path)=="") { return FALSE; } $d = dir($path); while (false !== ($entry = $d->read())) { if ($entry!="." and $entry!="..") { if (time()- filemtime($path."/$entry") < 1 * 60) { $i++; } } } $d->close(); return $i; }
Krydos Posted October 12, 2020 Posted October 12, 2020 Did you set read permissions for other on that file? You can right click on the file in cpanel file explorer or use ftp to change permissions. Filezilla calls other public permissions for instance.
mrj Posted October 12, 2020 Author Posted October 12, 2020 Did you set read permissions for other on that file? You can right click on the file in cpanel file explorer or use ftp to change permissions. Filezilla calls other public permissions for instance.Yes, I did. I set it to 777.
mrj Posted October 12, 2020 Author Posted October 12, 2020 I read somewhere in the internet that shared hosting sessions are saved to the same path for everyone. Maybe is that why particular user can't read session dir? Just an Idea.
Krydos Posted October 12, 2020 Posted October 12, 2020 666 is better unless you need to execute the file for some reason. 6 = read/write, 7 = read/write/execute. Directories generally need execute permissions, but unless the file is cgi or a command line script it doesn't need execute. Try changing the directory that the files are in to 777 though.
Krydos Posted October 12, 2020 Posted October 12, 2020 Well, you can set the session path to whatever you want with ini_set('session.save_path', $path);
mrj Posted October 12, 2020 Author Posted October 12, 2020 666 is better unless you need to execute the file for some reason. 6 = read/write, 7 = read/write/execute. Directories generally need execute permissions, but unless the file is cgi or a command line script it doesn't need execute. Try changing the directory that the files are in to 777 though.Still not working
mrj Posted October 12, 2020 Author Posted October 12, 2020 Well, you can set the session path to whatever you want with ini_set('session.save_path', $path); tried, but still shows the session path asĀ /var/cpanel/php/sessions/ea-php73
Krydos Posted October 12, 2020 Posted October 12, 2020 Works for me <?php echo session_save_path()."<br>"; ini_set("session.save_path", "/home/krydos/tmp"); echo session_save_path(); https://krydos.heliohost.org/session_change.php
mrj Posted October 12, 2020 Author Posted October 12, 2020 here is my output /var/cpanel/php/sessions/ea-php73 /var/cpanel/php/sessions/ea-php73
Krydos Posted October 12, 2020 Posted October 12, 2020 Hmm, it works on your account too https://merajbd.com/session_change.php
mrj Posted October 12, 2020 Author Posted October 12, 2020 (edited) Okay I figured out the problem. ini_set function need to be called at the top of php file. inside a function doesn't work. Edited October 12, 2020 by mrj
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now