I am using a simple code to check if session variable is not set then page redirect to another page usign javascript. My code is:
var userLogin = "<?php echo $_SESSION['user']['id']; ?>";
if (typeof userLogin == "undefined")
{
$(location).attr('href', 'http://www.example.com/');
}
But it's not working because if session is not set then it assign:
var userLogin = "";
My question is: What is difference between both variable declaration:
var userLogin = "";
and
var userLogin;