Print Email Address on home page using SESSION after successful login PHP -
i trying use session store email address , print on home page after successful login. here have tried keep getting undefined variable error $email. know email address getting stored because appears in "inspect element--> resources --> localhost" here code far. appreciate or advice on how correct going wrong.
<?php session_start(); if (isset($_session['email'])) { $email=$_session['email']; } echo "welcome homepage: ".$email; ?>
you getting undefined variable error because $email
set if session variable exists.
fix:
if (isset($_session['email'])) { $email = $_session['email']; } else { $email = '<unknown>' }
possible cause: misconception how session works / sequence of request , response events.
Comments
Post a Comment