Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 6th, 2004, 04:35 AM
Authorized User
 
Join Date: Oct 2003
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default Session problem?

i've got the following error :
Warning: session_start(): open(/tmp\sess_b44ffdfc75e9ae187cb49d968c8db84a, O_RDWR) failed: No such file or directory (2) in c:\inetpub\wwwroot\project\auth_user.php on line 2

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at c:\inetpub\wwwroot\project\auth_user.php:2) in c:\inetpub\wwwroot\project\auth_user.php on line 2

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at c:\inetpub\wwwroot\project\auth_user.php:2) in c:\inetpub\wwwroot\project\auth_user.php on line 2

Warning: Unknown(): open(/tmp\sess_b44ffdfc75e9ae187cb49d968c8db84a, O_RDWR) failed: No such file or directory (2) in Unknown on line 0

Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0

below are my code. Please help me! What's wrong with it?


<?php
session_start();
include "common_db.inc";

function auth_user($userid, $userpassword)
{
    $query = "SELECT username FROM $user_tablename WHERE username = '$userid' AND password = password('$userpassword')";
    $result = mysql_query($query);
    if(!mysql_num_rows($result)) return 0;
    else
    {
           $query_data = mysql_fetch_row($result);
           return $query_data[0];
    }
}

function login_form( )
{
    global $PHP_SELF;
?>
<HTML>
<HEAD><TITLE>Login</TITLE></HEAD>
<BODY><FORM METHOD="POST" ACTION="<? echo $PHP_SELF ?>">
<DIV ALIGN="CENTER"><CENTER>
<H3>Please log in to access the page you requested.</H3>
<TABLE BORDER="1" WIDTH="200" CELLPADDING="2">
    <TR>
        <TH WIDTH="18%" ALIGN="RIGHT" NOWRAP>ID</TH>
        <TD WIDTH="82%" NOWRAP> <INPUT TYPE="TEXT" NAME="userid" SIZE="8"> </TD>
    </TR>
          <TR>
        <TH WIDTH="18%" ALIGN="RIGHT" NOWRAP>Password</TH>
                  <TD WIDTH="82%" NOWRAP>
 <INPUT TYPE="PASSWORD" NAME="userpassword" SIZE="8"> </TD>
    </TR>
    <TR>
        <TD WIDTH="100%" COLSPAN="2" ALIGN="CENTER" NOWRAP>
 <INPUT TYPE="SUBMIT" VALUE="LOGIN" NAME="Submit"> </TD>
     </TR>
</TABLE>
</CENTER></DIV>
</FORM>
</BODY>
</HTML>
<?
}


if(!isset($userid))
{ login_form();
    exit;
}
else
{
    session_register("userid", "userpassword");
    $username = auth_user($userid, $userpassword);
    if(!$username)
    {
        session_unregister("userid");
        session_unregister("userpassword");
        echo "Authorization failed. " .
        "You must enter a valid userid and password combo. " .
        "Click on the following link to try again.<BR>\n";
        echo "<A HREF=\"$PHP_SELF\">Login</A><BR>";
        exit;
     }
    else
        echo "Welcome, $username!";
}

?>








 
Old January 6th, 2004, 12:49 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

This post is virtually identical to problems presented in these posts:
http://p2p.wrox.com/topic.asp?TOPIC_ID=8046
http://p2p.wrox.com/topic.asp?TOPIC_ID=8169

Check your session.save_path directive in php.ini, and that you have set the proper read/write permissions on that directory. Let us know if solutions presented in the aboves threads come to naught.

: )
Rich



:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
 
Old January 9th, 2004, 08:57 AM
Authorized User
 
Join Date: Oct 2003
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much for your help.
i'm sory because i don't know there are identical problem earlier.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Session Out Problem kasipandian J2EE 3 March 21st, 2008 03:35 PM
session problem MunishBhatia ASP.NET 2.0 Professional 9 October 6th, 2007 04:06 AM
Session problem abdulweb General .NET 3 August 27th, 2007 08:01 PM
session and cookie problem (empty session file) msincan BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 February 27th, 2005 05:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.