Problem with Session Variables

Hi,

I’m trying to create a login page. Here’s my code:

[php]
if (isset($_POST[“Submit”])){
$strUser = funcStripText($_POST[“txtUser”]);
$strPass = funcStripText($_POST[“txtPass”]);

if (($strUser != "")&&($strPass != "")){
	$rsRow = mysqli_query($connBike, "SELECT UserID FROM tbl_Users WHERE Username='" . $strUser . "' AND UserPass='" . $strPass ."'");
	if (mysqli_num_rows($rsRow)>0){
		$rsDetails = mysqli_fetch_assoc($rsRow);
		mysqli_free_result($rsRow);
		mysqli_close($connBike);
		
		session_start();
		$_SESSION["UserID"] = $rsDetails["UserID"];
		$intStatus = 1;
	}
	else{
		$intStatus = 2;
	}
}

}
[/php]

This seems to work fine, but as soon as I navigate to another page in the site it logs me out, almost as if there’s a session_destroy() on every other page, which there isn’t.

Any ideas what I’m missing?

Hello, How you described the problem, i think in the another page you don’t started the session again, always that you redirect to another page, you need to session_start… But if it isn’t the problem, please, explain me better the problem…

OK, so I need session_start(); on each page within the site.

Thanks very much, working perfectly now. :slight_smile:

you’re welcome :smiley:

If you want other help, contact me on gtalk -> [email protected]

Sponsor our Newsletter | Privacy Policy | Terms of Service