Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session problem

Status
Not open for further replies.

tcardoso

Programmer
Jan 31, 2005
56
PT
I have this error on my server many times:
open(/tmp/sess_81516e1e3235a35d2f5ade72ccde4acd, O_RDWR) failed: Permission denied (13)

I have /tmp directory with 777 permissions, session.save_path set to /tmp.

What can I do more?

Thanks

P.S. - There is a better forum for this doubt?
 
run this script

Code:
$dir = '/dir';
if (is_readable($dir)) {
 echo 'temp directory is readable<br/>';
} else {
 echo 'temp directory is not readable<br/>';
}

if (is_writable($dir)){
 echo 'temp directory is writable<br/>';
} else {
 echo 'temp directory is not writable<br/>';
}

and see what php reports
 
for that /dir directory it returns:
temp directory is not readable
temp directory is not writable

But if I put /tmp directory it gives
temp directory is readable
temp directory is writable

I access server with ssh and permissions are 777 on /tmp
 
i'd meant to set the variable to /tmp, so thanks for fixing that.

i can't think what else to test though. if the /tmp dir is readable and writable (which it should be) then there seems no reason why php should not be able to read and write the session information.

if the error always relates to this file
sess_81516e1e3235a35d2f5ade72ccde4acd
then it may be/have been something to do with a file lock on that file. if the file still exists in your tmp directory have a look at the permissions on that file and see whether something has gone wrong.

alternatively the permission denied message could have been to do with file locks. i.e. php was still writing to the file when the next script tried to read from it. this is called a 'race condition' and can happen when page refreshes are _very_ fast. typically this will only happen when you are using the local machine. this seems unlikely if you are having to ssh in order to determine the permissions. To ensure that race conditions do not occur, then use
Code:
session_write_close();
at the end of your scripts.
 
Tell me if this is possible?

We change servers now! And we copy all the content in HDD, when I ssh that directory and check the files I see that some files have the owner and group prisonst (our local account) and others have owner and group nobody and have 0bytes on it!

probably they are old files from old server and now apache can't access them!

Do you think this is possible? And in that case how can I delete the files owned by nobody? (whats the linux command).

Thanks for your help
 
what user is apache running under? often it is 'nobody'

anyway, to delete files from a *nix server you would use the rm command. type man rm into a terminal for more information.
 
Just so that other that may have the same problem. I delete the files owned by nobody and now, no error appears!

I think thats because old server had an old version of apache and now this one could not access the session files created by the other so it returned that error.

Thanks jpadie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top