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

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

node.js - How to abort query on demand using Neo4j drivers -