7

I'm trying to start the session in a header page in my webiste. But it seems there might be some sort of bug because it fails with the following error:

Warning: session_start() [function.session-start]: open(\xampp\tmp\sess_a7430aab4dd08d5fc0d511f781f41fe5, O_RDWR) failed: No such file or directory (2) in D:\Development\PHP\tt\Include\header.php on line 3

I'm using the default settings for xampp, everything is straight out of the box. For some reason its failing to open the file. however when i go to the directory with the session files in it, the files are there, they are just empty. Is this a bug? or am I doing something wrong?

php version 5.2.8

The.Anti.9
  • 43,474
  • 48
  • 123
  • 161
  • 1
    @SHOBAN I don't think there is anything that can be done in calling session_start() that can cause this error, there is no need to see the code. – UnkwnTech Mar 22 '09 at 06:41

3 Answers3

13

First stop the Xampp Server.

session.save_path = "\xampp\tmp"

and change it to look like this

session.save_path = "C:\xampp\tmp"

Restart the Xampp Server.

That’s it now your session should work as expected.

Selular88
  • 131
  • 1
  • 2
  • Problem is the directory must exist. – quantum Oct 28 '12 at 03:59
  • This question already has an accepted answer. Unless your answer add relevant information, or corrects a mistake found in the current answers, you shouldn't post an answer. – Madara's Ghost Oct 28 '12 at 09:15
  • 1
    @MadaraUchiha There is a comment to the accepted answer that states that it didn't solve the problem. So adding an actually working answer should not be a mistake. – Tarnschaf Jan 28 '13 at 13:01
  • 2
    Accepted answer didnt solve my problem, whereas this post does. So thumbs up for this one. – Sgali Feb 13 '13 at 17:10
  • 1
    Like for Sgali, this fixed it for me (Okay I changed to directory to a path outside C:\ but still, thanks for the hint!) – tim Dec 16 '13 at 15:36
  • This is the real solution. I came across this problem after running an app(virtual host) in a drive(F:) different from the one where xampp(C:) is installed. Then xampp was looking for the session folder on the F: drive. – Lennon Nov 11 '14 at 17:54
11

This means that you don't have the correct permissions to either read or write the files in the temp directory.

If you on linux then do this

sudo chmod -R 755 \xampp\tmp //or should it be 775

On windows do this as an administrator

attrib -r -a C:\xampp\tmp /S
UnkwnTech
  • 88,102
  • 65
  • 184
  • 229
  • 1
    It was giving me a file not found error, so I added /D at the end and it went through. Unfortunately this didn't solve the problem – The.Anti.9 Mar 22 '09 at 13:05
  • 1
    If I right click on the folder and go to properties, read only is checked. But if I uncheck it, hit apply, and then right click and go back to properties, its checked again. – The.Anti.9 Mar 22 '09 at 13:17
  • Than you probably don't have the proper privelages to change the permissions. – UnkwnTech Mar 22 '09 at 20:13
  • 1
    I'm logged in as administrator. I solved the problem by changing the directory it uses in php.ini – The.Anti.9 Mar 22 '09 at 21:09
0

As Selular88 mentioned, Adding the path works and fix this issue. You can also check the path using

// This will output your current path.
echo session_save_path() ;
Dexter
  • 7,911
  • 4
  • 41
  • 40