I have a function which deals with sessions and cookies.
functions.php
function getUser()
{
if(isset($_COOKIE["auth"]))
{
/* check cookie */
echo $_COOKIE['auth'];
}else if(isset($_SESSION["auth"])){
echo $_SESSION["user_auth"];
}
}
I also have a form and there's an alert associated with it. I have an ajax that when user submits the form, alert the function.
Everything works, but the only issue is that the alert pops up with lots of spaces in it. I've tried to use
trim(getUser);
and str_replace("","",getUser());
And this is causing me problems because I'm trying to input the session value or cookie value into mysql database. When I check if there's any values inside my mysql database, its just empty, and its not NULL.
Thanks!
AJAX:
form.php
$(".inputSubmit").submit(function(e){
e.preventDefault();
var inputs= $('.inputForm').serialize();
$.ajax({
url: "submit.php",
type: "POST",
data: input,
error: function(data){
alert(data.responseText);
alert(data.responseStatus);
alert(data);
}
}).done(function(data){
alert(data);
});
});
submit.php
require "functions.php";
$users = str_replace("","",getUser());
echo $users;
lets say i have the alert box:
--------------------------------------
| |
| |
| |
| |
| |
| 1 |
| |
| |
| OK |
--------------------------------------
the 1 is the session output. the okay is the ok button when alert is popped out. Usually the 1 should be higher and smaller alert box, but its expanded as if there's white space.