PDA

View Full Version : Strange Errors With Membership System


DR.Wong
04-18-2006, 05:42 PM
Hey all... I am still learning PHP, as those of you who have read my other posts will know... I am trying to add a membership system to my site (just a small one, nothing special) and I came accross a tutorial that consists of 6 pages (things like login, connect, register, logout and so on....)

However, on all of these pages, I get the same set of errors, but only ONE error actually tells me what page is not working. I have a feeling that it is a permissions problem, the servers I am using do not allow me to alter my php.ini nor do they let me chmod anything, they claim that it gets done automatically.

Here are the errors I am getting :

Warning: open(/tmp/sess_beada5f1776cc265fa62133ce8a6ea10, O_RDWR) failed: No such file or directory (2) in /www/cgi/users/check_login.php on line 5

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

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


and here is the page (check_login.php) that it refers to :
<?php

/* check login script, included in db_connect.php. */

session_start(); //this line 5 where the error occurs!!!*****************

if (!isset($_SESSION['username']) || !isset($_SESSION['password'])) {
$logged_in = 0;
return;
} else {

// remember, $_SESSION['password'] will be encrypted.

if(!get_magic_quotes_gpc()) {
$_SESSION['username'] = addslashes($_SESSION['username']);
}


// addslashes to session username before using in a query.
$pass = $db_object->query("SELECT password FROM users WHERE username = '".$_SESSION['username']."'");

if(DB::isError($pass) || $pass->numRows() != 1) {
$logged_in = 0;
unset($_SESSION['username']);
unset($_SESSION['password']);
// kill incorrect session variables.
}

$db_pass = $pass->fetchRow();

// now we have encrypted pass from DB in
//$db_pass['password'], stripslashes() just incase:

$db_pass['password'] = stripslashes($db_pass['password']);
$_SESSION['password'] = stripslashes($_SESSION['password']);



//compare:



if($_SESSION['password'] == $db_pass['password']) {
// valid password for username
$logged_in = 1; // they have correct info
// in session variables.
} else {
$logged_in = 0;
unset($_SESSION['username']);
unset($_SESSION['password']);
// kill incorrect session variables.
}
}


// clean up
unset($db_pass['password']);

$_SESSION['username'] = stripslashes($_SESSION['username']);

?>

Does anyone know what is going wrong?

Could it be a php.ini problem?

Even if you cant help me solve the prob, please let me know what you think..

Thanks alot!:) :thumbsup:

cdwhalley.com
04-18-2006, 06:08 PM
I did a bit of googling for you. Looks like you need to change session.save_path and point it 'to your temp directory' if you are using windows - source (http://www.php4hosting.co.uk/php_faq/local/100/). To be honest, I have no idea where that would be, but to change the session.save_path the code would be:

$temp_directory="";//put 'temp directory' here
ini_set("session.save_path", $temp_directory);

DR.Wong
04-18-2006, 06:40 PM
Thank you cdwhally. I am not sure where to place this code, but it is a step in the right direction by the look of it!

Thanks for your input!