views:

28

answers:

2

Hi,

I think I'm having problems using PHP sessions because I've got cPanel installed on the same server and I believe it has additional security in place that prevents write access to /tmp

I can set a new folder, but am unsure what permissions / owners should this folder have.

Also where should it ideally be located?

A: 

/tmp should always be accessible. You can of course create a new "tmp" folder somewhere near you application. Just make sure it does not reside within the web root. Give it read/write permissions and chown it to the user of the webserver.

You then need to change the session_save_path to your new "tmp" folder.

halfdan
Apparently cPanel restricts access to /tmp as a security precaution. I had similar issues when I was installing a .sh file (located elsewhere, but which needed to create files in /tmp). So, /temp wouldnt be a good idea?
tzmatt7447
+2  A: 

Look, bro.
You are pulling this log from the wrong end. Guessing will never help you.

There is a thing called error message.
And you desperately need to get in touch with it.
It will tell you everything of the reasons why your sessions doesn't work.

If it's really a /tmp problem, PHP got a special error message for tis case:

Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp))

If you get this message, you can be certain that it's the reason for your sessions doesn't work and you can start to repair it.

It has an error message for the wrong session handler as well. As well for the every other problem.

So, you have to get error message first. Then read it nd it makes you know, what certain problem you have. Easy-peasy.

As a quick workaround you can use this code to bring error messages on the screen

error_reporting(E_ALL);
ini_set('display_errors',1);

but only to debug this situation and then remove it. Error messages shouldn't be output on the screen a production server.
So, learn to read error logs. I am sure your server put all errors messages into error_log. Just find it and look for PHP errors.

Col. Shrapnel
Thanks sis - but that wasn't helpful. I have that setup and php is _not_ outputting an error message.
tzmatt7447
+1 I laughed so hard.
halfdan
Perhaps it's time to start up a CW on basic PHP debugging. Far too many "it's broken, fix it" questions where a simple poke at an error log would tell all on what needs to be fixed.
Marc B