Skip to main content

shared hosting user home folder tmp directory -- can I use this for php sessions?

Comments

6 comments

  • SS-Maddy
    Hello The location /home/user/tmp is used for various stats and hence setting a cron to delete the folder contents is not recommented. You can create a seperate directory and set the path to that directory. Normally session files are removed automatically as per the configuration, otherwise you can set a cron using find command to delet files of its last access time.
    0
  • cPanelMichael
    Hello :) [QUOTE]By default on a shared hosting server generally session.save_path is /tmp. This is bad for a couple reasons such as other users on the server can read the data AND even garbage collect the session before it really should.
    Other users should not be able to read sensitive information from the /tmp partition. Please feel free to provide a specific example of this. Note that you can use an alternative /tmp partition, but do not delete the contents of "/home/$user/tmp" because it contains important data such as statistics. Thank you.
    0
  • cmuench333
    [quote="cPanelMichael, post: 1698791">Hello :) Other users should not be able to read sensitive information from the /tmp partition. Please feel free to provide a specific example of this. Note that you can use an alternative /tmp partition, but do not delete the contents of "/home/$user/tmp" because it contains important data such as statistics. Thank you.
    I am asking if using /home/$user/tmp can be used for php sessions. I read the first comment and it seems there is a cron that clears out that folder. Is this true? Also /tmp php session files are created by nobody and a php script could simply run that reads from /tmp easily.
    0
  • cPanelMichael
    [quote="cmuench333, post: 1699101">I am asking if using /home/$user/tmp can be used for php sessions. I read the first comment and it seems there is a cron that clears out that folder. Is this true?
    No, that is not accurate. There are no default cron jobs that clear out the tmp directory in "/home/$user" and there should not be because important data is stored in that location. Thank you.
    0
  • cmuench333
    [quote="cPanelMichael, post: 1699161">No, that is not accurate. There are no default cron jobs that clear out the tmp directory in "/home/$user" and there should not be because important data is stored in that location. Thank you.
    So is it safe to change session directory to this directory instead of /tmp? (it seems phpMyAdmin already does this)
    0
  • cPanelMichael
    Yes, that's fine. I would still make it a subdirectory (e.g. /home/$username/tmp/123) for better organization. Thank you.
    0

Please sign in to leave a comment.