Question

I am passing php session vars via Meta Refresh. I see the vars posted on the next page in url. How do I take control of them on the new page to use them in a form on that page.

Something along the lines of: (Pseudo Code)

(isset($_REQUEST['firstname']){
    $_SESSION['firstname']= $_REQUEST['firstname'];
    echo $_SESSION[firstname];
}

This is my code

session_start();

$_SESSION['firstname']=$firstname;
$_SESSION['lastname']=$lastname;
$_SESSION['email']=$email;

//$url='/nextpage.php';
//echo '<META HTTP-EQUIV=REFRESH CONTENT="1; '.$url.'">';

echo '<meta http-equiv="refresh" content="1;url=/nextpage.php?firstname='.$_SESSION['firstname'].'&amp;lastname='.$_SESSION['lastname'].'&amp;email='.$_SESSION['email'].'" />';

exit;
Was it helpful?

Solution

After a scratching and searching for a solution with no luck I finally resolved this way:

 <form name="form" id="form" method='post' action='nextpage.php'>

<input type="hidden" name="firstname" value="<?php echo $_SESSION['firstname'];?>" />
<input type="hidden" name="lastname" value="<?php echo $_SESSION['lastname'];?>" />
<input type="hidden" name="email" value="<?php echo $_SESSION['email'];?>" />

on my next page I assigned the vars to session using post.

  $_SESSION['firstname'] = $_POST['firstname'];
  $_SESSION['lastname'] = $_POST['lastname'];
  $_SESSION['email'] = $_POST['email'];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top