Values retrieved using JS localStorage differs in PHP
Below is the php code which would take the session variables using JS.The
values retrieved are correct but mysql query returns zero.But if i
hardcode the same values the mysql query is passing.Appreciate your
help.Thanks in advance.Below is the code. test.php
$msessionEmail =
"<script>document.write(localStorage.getItem(\"sessionEmailID\"));</script>";//Retrieves
"hello@test.com"
$msessionPassword =
"<script>document.write(localStorage.getItem(\"sessionPassword\"));</script>";//Retrieves
"test"
$sessionEmail="hello@test.com";
$sessionPassword="test";
echo gettype($msessionEmail);//it is string
echo gettype($sessionEmail);//it is string
echo $msessionEmail;//hello@test.com
echo $sessionEmail;//hello@test.com
if($msessionEmail==$sessionEmail)
{
echo "equal";
}
else
{
echo "not equal";//This gets printed but their values are same.
}
No comments:
Post a Comment