setcookie - display Email of User on HomePage After login using Cookies PHP -


i trying use cookies display users email address on home page after log in. have used setcookie($email); in loginbase page , using following code wont work. not sure if on right track or not. appreciate advice it. thanks.

<?php $email = $_cookie['email'];   echo "welcome '" . $email . "; ?> 

loginbase.php

<?php    //start session  require_once("functions.php"); sec_session_start();  //get informations $email = $_post['inputemail']; $password = $_post['inputpass']; $nextpage = "home.php";  if(isset($email) && isset($password)) {     //database connection     $connection = mysqli_connect("localhost", "root", "");     mysqli_select_db($connection, "dairy herd system");      //prepare statement query     //$statement = mysqli_prepare($connection, "select hash_password, salt user e_mail = ? limit 1");     $statement = mysqli_prepare($connection, "select password user email = ? limit 1");     //add data query     mysqli_stmt_bind_param($statement,"s", $email);      //execute query     mysqli_stmt_execute($statement);      //get result of query     mysqli_stmt_bind_result($statement, $password);      if (mysqli_stmt_fetch($statement) )      {          // user-agent string of user.         //$user_browser = $_server['http_user_agent'];          //$_session['email'] = $email;         //close database connection         mysqli_stmt_close($statement);         mysqli_close($connection);         setcookie('email', $email)          // login successful.        header("location: home.php");      }     else     {         //close database connection         mysqli_stmt_close($statement);         mysqli_close($connection);          header("location: login.php?error=logininvalid");     }  } else {     header("location: login.php?error=logininvalid"); }     ?> 

when setting cookie try

setcookie('email', $email) 

this should set cookie named email value of $email

the way indicating you're setting setting cookie name of users email , no value

http://php.net/manual/en/function.setcookie.php


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -