PHP - accessing one html values in another html using single php file -


i want access value send first.html test.php using ajax, , value send second.html, achieve tried both session , cookies. i'm not putting complete code basic structure this

first.html

<html>     send value test.php  </html>  

second.html

<html>       access value test.php   </html>  

test.php

<?php    if(execute when request comes first.html){      $cookie_name = "user";      $cookie_value = "john doe";      setcookie($cookie_name, $cookie_value, time() + (86400 * 30));      echo " "; } else if(execute when request comes second.html){     if(!isset($_cookie[$cookie_name])) {     echo "cookie named '" . $cookie_name . "' not set!";     } else {     echo "value is: " . $_cookie[$cookie_name];    } } else{      $cookie_name = "user";      $cookie_value = "john doe";      setcookie($cookie_name, $cookie_value, time() + (86400 * 30));      if(!isset($_cookie[$cookie_name])) {      echo "cookie named '" . $cookie_name . "' not set!";      } else {      echo "cookie '" . $cookie_name . "' set!<br>";      echo "value is: " . $_cookie[$cookie_name];     } } ?> 

when execute test.php file directly in localhost works perfectly(last else part only) , wrong code or doing wrong. btw i'm using php file both files different other operations , working fine. please me out. thanks.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -