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
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)
You can use your own directory where session save.
Put below code above session_start(); code.
$sessdir = dirname(dirname(__FILE__)).'/session_dir';
ini_set('session.save_path', $sessdir);
Enjoy!!!!!!!!!!
I had a different problem - no errors but sessions were not working after installing php / apache on linux. I spent hours researching this and finally solved the problem by simply deleting the contents of /tmp.
Thanks to KramerC
精彩评论