PHP session.save_path, is there a way to set this globally to use what ever the user account is writ

golden_eyes

Well-Known Member
Aug 9, 2010
88
1
58
Hello,

I know how to set the session.save_path in the php.ini manually to the current user. But is there a way to write it so it detects the current user?

let us say we have 100 accounts on the server, they cant just all save sessions to /tmp, so they need to be saved on a per user account directory basis (something like /tmp/USERNAME or /home/USERNAME/tmp) However; currently I would need to manually type this into the php ini. Is there a way I can write the file once, or change some server config so that it just puts the user account name in automatically.

So maybe on the server or in the php.ini file it would say something like:
session.save_path = "/home/${USERNAME}/tmp"

Is there a way to do this? Or a way to make the server generate the settings per account for me?

Thanks in advance...
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,202
363
Re: PHP session.save_path, is there a way to set this globally to use what ever the user account is

Hello :)

You could place an individual php.ini file within each account if you are using a handler that supports it (e.g. suPHP). You could develop a script that automatically updates that path for each php.ini file that's copied to the account's home directory.

Thank you.
 

golden_eyes

Well-Known Member
Aug 9, 2010
88
1
58
Re: PHP session.save_path, is there a way to set this globally to use what ever the user account is

Thank you for reply.

In this case I'm allowing the users to update the php.ini and enabling some functions that are disabled globally, the safe_mode is too critical, when I disable it from the global php.ini, the user can enable it from his php.ini.

Is there another idea could cover my needed?

Please note that the purpose of this request is when I run the /scripts/securetmp it apply permission that couldn't be used by the php script as you see the error below:
Warning: session_start(): open(/tmp/sess_cb74e63e592957cffb4231f421282590, O_RDWR) failed: Permission denied (13)
 

Misiek

Well-Known Member
Feb 23, 2004
116
0
166
cPanel Access Level
Root Administrator
Re: PHP session.save_path, is there a way to set this globally to use what ever the user account is

That's basically something wrong but not with secure tmp that should not affect writing session files to tmp. Do You use suPHP
 

golden_eyes

Well-Known Member
Aug 9, 2010
88
1
58
Re: PHP session.save_path, is there a way to set this globally to use what ever the user account is

Yep, I'm using the suPHP and gettting the error
 

Misiek

Well-Known Member
Feb 23, 2004
116
0
166
cPanel Access Level
Root Administrator
Re: PHP session.save_path, is there a way to set this globally to use what ever the user account is

Yep, I'm using the suPHP and gettting the error
Basically You can place in each public_html in .htaccess line
suPHP_ConfigPath /home/user/
Then place in this folder each time You crate an account php.ini file, then You will have custom php.ini on each account.
Second way You can just set session.save_path to folder like /home/sessions/ and on this folder give permission 777 then in php.ini add to disable_functions = phpinfo, and thats it.
 

sailendra

Registered
Nov 25, 2014
1
0
1
cPanel Access Level
Website Owner
Re: PHP session.save_path, is there a way to set this globally to use what ever the user account is

No the above code doesn't use because this gives error
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,202
363
Re: PHP session.save_path, is there a way to set this globally to use what ever the user account is

No the above code doesn't use because this gives error
Could you elaborate on the specific error message you are receiving? Do you have root access to this system?

Thank you.