Jump to content

will this actually work?


clown[NOR]

Recommended Posts

basicly what i wanna do is to try keeping the $_SESSION's linked to the login alive... will this work or not?

<?php
function chkLogin() { // Check if user is logged in or not.
	if (!$_SESSION['id'] || !$_SESSION['userID'] || !$_SESSION['pass'] || !$_SESSION['sid']) { return FALSE; }
	else {
		con2db();
		$id=mysql_real_escape_string($_SESSION['id']);
		$user=mysql_real_escape_string($_SESSION['userID']);
		$pass=mysql_real_escape_string($_SESSION['pass']);
		$dbq="SELECT * FROM `users` 
				WHERE `userID`='$user'
				AND `pass`='$pass'
				AND `active`='1'
				LIMIT 1
				";
		$result=mysql_query($dbq);
		if (!$result) { return FALSE; }
		else {
			$num=mysql_num_rows($result);
			if ($num!=1) { return FALSE; }
			elseif ($num==1) { 
				$_SESSION['id']=$_SESSION['id'];
				$_SESSION['userID']=$_SESSION['userID'];
				$_SESSION['pass']=$_SESSION['pass'];
				$_SESSION['sid']=$_SESSION['sid'];
				return TRUE;
			}
		}
	}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/98789-will-this-actually-work/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.