I am trying to create a simple log in system that uses ajax but the problem I am having it wont set the $_SESSION.
login.js:
$('#bt-login').click(function(){
var login = $('#login').serialize();
$.ajax({
type: "POST",
url: 'widgets/Login/loginFunction.php',
data: login,
cache: false,
success: function(msg){alert(msg)}
});
});
loginFunction.php:
<?php
include_once '../../dbConfig.php';
include_once '../../config.php';
session_start();
$usr = mysql_escape_string($_POST['username']);
$pass = mysql_escape_string($_POST['password']);
$remember = intval($_POST['rememberMe']);
$row = mysql_fetch_assoc(mysql_query("SELECT usr, id FROM members WHERE usr='".$usr."' AND pass='".md5($pass)."'"));
if($row['usr']){
$_SESSION['usr'] = $row['usr'];
$_SESSION['id'] = $row['id'];
$_SESSION['rememberMe'] = $remember;
setcookie('DirtPileGames',$remember);
}
?>
Now for some reason loginFunction.php is not setting the $_SESSION. I do a refresh and $_SESSION is blank.
Does anyone have any ideas why this wont work.