[solve] warning after using session_start()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
unix77
Forum Newbie
Posts: 7
Joined: Tue Jun 07, 2005 6:13 am
Location: south korea

[solve] warning after using session_start()

Post 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
Last edited by unix77 on Tue Jun 07, 2005 6:55 am, edited 1 time in total.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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"
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post 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.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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 ;)
Post Reply