Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP Sessions not saving to /tmp folder

Discussion in 'General Discussion' started by martin MHC, Jan 2, 2017.

Tags:
  1. martin MHC

    martin MHC Active Member

    Joined:
    Sep 14, 2016
    Messages:
    43
    Likes Received:
    6
    Trophy Points:
    8
    Location:
    UK
    cPanel Access Level:
    Root Administrator
    Hello
    I have a curious recent issue.
    I have a host of accounts (90) on a server. Most are using custom php.ini settings to save sessions to account specific folders, however some do not, and use the default folder.

    This is typically home/<accountname>/tmp and has worked without problem until some time recently.

    I was alerted that the default catchall account was overflowing, and found that there was gigabytes of session files in the <serveraccount>/tmp folder. I had to delete them to reclaim disk space, but it lead to an interesting line of research:

    1) Background:
    -- Easy Apache 4,
    -- PHP 5.6.2
    -- WHM 60 build 28
    -- MultiPHP installed, PHP handler suPHP.

    2) Central PHP file:

    session.save_path = "/tmp"

    (I have also tried with removing the quotes as well, but this doesn't seem to make any difference.

    The issue is that CPanel PHPMyAdmin correctly saves it's session data to the account /tmp folder as expected. But the PHP used by the site itself does not do this, instead saving to the catchall server account.

    What am I missing? What should I change to revert the actions to saving website sessions in the temp folder as has previously been happening?

    Accounts where I have set a custom session destination path from within the account are not at all effected.

    Cheers


    UPDATE:
    I changed the PHP version to 7.0.1 in MultiPHP Manager and applied to the same account but this persisted in still not saving sessions to the expected account temporary folder /tmp .
     
    #1 martin MHC, Jan 2, 2017
    Last edited: Jan 3, 2017
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,427
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    phpMyAdmin uses it's own internal cPanel PHP version and configuration file, and isn't related to the version of PHP utilized by your website.

    You'd have to setup a custom php.ini file with a custom session.save_path value (e.g. /home/$username/tmp) if you prefer that it not use the default /tmp location on the server. Information on custom php.ini values with suPHP and MultiPHP is available at:

    In Progress - EA4 php.ini/local.ini behavior

    Let us know if this helps.

    Thank you.
     
  3. martin MHC

    martin MHC Active Member

    Joined:
    Sep 14, 2016
    Messages:
    43
    Likes Received:
    6
    Trophy Points:
    8
    Location:
    UK
    cPanel Access Level:
    Root Administrator
    PRECURSOR:
    I can't seem to edit my original post:

    account session files are being saved to /var/tmp NOT to any other account on the server but to the /var/tmp folder of the server itself.

    This is account session files from all accounts which do not have account specific savepath redirections.This is not the address specified in the php.ini on WHM and I'm unclear how this address is reached. Any clarity here would be appreciated.

    =======


    Hi Michael,
    My situation seems to have changed slightly. I was given slightly erroneous information from my colleague. I will update the original Q.

    Previous to this week, this situation did not occur and session values were seemingly saved to /home/<account>/tmp as expected.

    Further current illustration:

    AccountA is a client account, and has no custom php.ini settings.
    AccountB is a client account and has custom php ini settings.


    When AccountA saves session data, the session data appears to work in the browser, but is NOT saved to /home/accountA/tmp folder but they are instead saved to /var/tmp , not in the folder specified in the running PHP.ini. Where are these sessions meant to be saved?

    When AccountB saves session data this data correctly saves to the locally specified folder. Local copy php.ini settings work as expected.


    To clarify yes, I am aware of custom.ini and do use this on some accounts, but the issue is accounts that use the default php.ini settings of either PHP versions installed (5.6 or 7) , do not save session files to the local account /tmp folder as would be expected but seem to save them to the drive folder /var/tmp , which seems very odd and a little worrying. Is this usual?

    Cheers
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,427
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    It's actually the default behavior for PHP to store session files in the system's /tmp directory. This is due to the following entry in the default php.ini file associated with the version of PHP:

    Code:
    ;session.save_path = "/tmp"
    Entries such as /tmp in this file refer to the /tmp directory on the system, not the account.

    Thank you.
     
  5. martin MHC

    martin MHC Active Member

    Joined:
    Sep 14, 2016
    Messages:
    43
    Likes Received:
    6
    Trophy Points:
    8
    Location:
    UK
    cPanel Access Level:
    Root Administrator
    Hello
    Previously sessions have always by default operated from the /tmp folder on the account, can you tell me how I can revert this to the previous account specific behaviour, and if you're aware of what caused the initial swap from <account>/tmp to <server>/var/tmp ? I was unaware of myself making any changes to cause this (my edits to Php.ini had been post- change rather tha pre-change.

    Cheers
    Martin
     
  6. martin MHC

    martin MHC Active Member

    Joined:
    Sep 14, 2016
    Messages:
    43
    Likes Received:
    6
    Trophy Points:
    8
    Location:
    UK
    cPanel Access Level:
    Root Administrator
    Is there a way of reverting to the account specific /tmp rather than system wide /tmp as previously happened?
     
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,427
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    It's always defaulted to the /tmp directory on the system unless you've utilized custom php.ini files or custom entries in the .htaccess file. There's an older thread where this is discussed:

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

    Is there any reason you prefer to not have session files saved in the server's global /tmp directory? This is the standard behavior and should not result in any problems with your applications.

    Thank you.
     
Loading...

Share This Page