Created
February 21, 2012 07:40
-
-
Save ZachMoreno/1874894 to your computer and use it in GitHub Desktop.
Session Start
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function authenticate_user($login, $password, $key) | |
{ | |
$val = set_codes(); | |
$query = "select * from users where login='$login' and password = encode('$password', '$key')"; | |
$result = mysql_query ($query); | |
$row = mysql_fetch_row($result); | |
if (mysql_num_rows($result) > 0) | |
{ | |
$_SESSION['auth'] = $val; | |
$_SESSION['id'] = $row[0]; | |
} | |
else | |
{ | |
$_SESSION['auth'] = "Incorrect Login"; | |
} | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$val = set_codes(); | |
if (!isset ($_SESSION['auth']) || $_SESSION['auth'] != $val) | |
{ | |
if (isset($_POST['username'])) | |
{ | |
authenticate_user (mysql_prep($_POST['username']), mysql_prep($_POST['password']), KEY); | |
} | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
if(isset($_GET['killsession'])) | |
{ | |
session_destroy(); | |
session_start(); | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function set_codes() | |
{ | |
if (!isset($_SESSION['validcode'])) | |
{ | |
$_SESSION['validcode'] = rand (1000000, 9000000); | |
$val = $_SESSION['validcode']; | |
return $val; | |
} | |
else | |
{ | |
$val = $_SESSION['validcode']; | |
return $val; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment