Jump to content

session var is not stored


shwetapandit

Recommended Posts

the session var email is not saves as when ai am using if-else to check session isset it goes to else clause why it is so and how i can save my session.

<?php
session_start();
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="regis"; // Database name
$tbl_name="regis"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// username and password sent from form
$email=$_POST['email'];
$pass=$_POST['pass'];

// To protect MySQL injection (more detail about MySQL injection)
$email = stripslashes($email);
$pass = stripslashes($pass);
$email = mysql_real_escape_string($email);
$pass = mysql_real_escape_string($pass);

$sql="SELECT * FROM $tbl_name WHERE email='$email' and pass='$pass'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);

// If result matched $email and $pass, table row must be 1 row

if($count==1){

$_session['email']="$email";

 

else {

echo "Wrong Username or Password";
}

if(isset($_SESSION['email']))
echo "amit";

 

else
echo "other";
}

?>
 

Link to comment
https://forums.phpfreaks.com/topic/283957-session-var-is-not-stored/
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.