Page 1 of 1

[solve] warning after using session_start()

Posted: Tue Jun 07, 2005 6:19 am
by unix77
Hi all

It is the first time for me to use session function. Below my simple list

Code: Select all

session_start();

        print("Session_id : ".session_id()."<br>");

        session_destroy();

        print("After close session <br>\n");
        print("Session_id : ".session_id()."<br>");

but in my browser, there are some warnings appear
Warning: session_start(): open(/tmp\sess_a1c40f1e51d34760eb047e976b402315, O_RDWR) failed: No such file or directory (2) in d:\belajar\php belajar\session\buatsesi.php on line 2

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at d:\belajar\php belajar\session\buatsesi.php:2) in d:\belajar\php belajar\session\buatsesi.php on line 2

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at d:\belajar\php belajar\session\buatsesi.php:2) in d:\belajar\php belajar\session\buatsesi.php on line 2
Session_id : a1c40f1e51d34760eb047e976b402315

Warning: session_destroy(): Session object destruction failed in d:\belajar\php belajar\session\buatsesi.php on line 6
After close session
Session_id :


how can it be happen? thanks

Posted: Tue Jun 07, 2005 6:25 am
by timvw
Read the manual http://www.php.net/session

And make sure to configure your "session.save_path" correctly.
For example, i've created a sessions directory in %win%/temp

session.save_path = "C:/windows/temp/sessions"

Posted: Tue Jun 07, 2005 6:27 am
by CoderGoblin
The error "headers already sent" means you have something out to the "page" before the session_start, be it an echo or:

Code: Select all

<html>
  <head>
  </head>
  <body>
<?php
  // body
?>
  </body>
</html>
(Even a blank line will cause the error).

The first error "/tmp\sess_a1c40f1e51d34760eb047e976b402315, O_RDWR) failed". Do you have read/write access to the /tmp directory. If not and you want to move where the "temporary" file storage area change your php.ini

Hopefully this gives you a couple of starting points to look for. I am sure someone will provide more detail.

Posted: Tue Jun 07, 2005 7:05 am
by timvw
Session object destruction failed in d:\belajar\php belajar\session\buatsesi.php


Makes me think he's using Windows :P
But as i already said, configuring session.save_path will solve that issue ;)