I need to do javascript action depends on $_SESSION php status:
if(isset($_SESSION['logged']) && $_SESSION['logged'] == true)
{
echo <<<END
$("#I-like-it").click(function()
{
$(this).css({"font-size": "20px" });
});
$("#I-dont-like-it").click(function()
{
$(this).css({"font-size": "20px" });
});
END;
}
else
{
echo 'alert("You must be logged in to vote!")';
}
This is external js file. How am I supposed to use PHP statements in this JS file? My code doesnt work :c
.phpextension in your js file. Anyway, i would re-think the solution if i were you because something isn't OK there. There shouldn't be PHP code in a JS code.