tags:

views:

68

answers:

2

I am designing a website in php.After completing it i uploaded the things in server. The page was working fine in localhost. But after uploading, the page is not even loading. At the top of every page i included a page called startsession.php. the contents of this page is as follows:

            session_start();
            header("Pragma: no-cache");
            header("Cache-Control: no-cache, must-revalidate");
            header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");

If I remove the session_start, it is working fine. The details of error is as follows:

Page in which Error Occured---Unknown

Line no in which error occured---0

Details Of the Error---Unknown(): open(/tmp/sess_723d94fdc8ae3569b1a641fd8799ece9, O_RDWR) failed: No such file or directory (2)

Error Code---2.

Please help me

A: 

Make sure /tmp/ exists and that the server has permission to write there.

If none of that works, try clearing /tmp/.

KramerC
+6  A: 

Check and make sure the path (/tmp) is writable by the user running the web server, as this may be a permissions problem. Also, you need to use the header() function BEFORE using session_start, as noted in the documentation:

http://php.net/manual/en/function.session-start.php

Since session_start may actually send the HTTP headers. Also, always make 100% certain you're using:

error_reporting(E_ALL)

Kristopher Ives
@Kristopher: +1 for a good explanation. Can you also tell, in which directory does PHP on windows save its session data, like /tmp/ in linux?
gameover
The placement for the header() function does not need to be before session_start(). I've in the past used the header() function after the session_start() without any problems.
KramerC
@gameover You can use this to get the current session directory:http://www.php.net/manual/en/session.configuration.php#ini.session.save-path@Kramer_Cambell Thanks, I have also used session_start() without problems, but the documentation specifically says it "sends" the headers, although I suspect it actually uses header() or buffers the changes until you output.
Kristopher Ives