从一个页面到另一个页面获取变量的值[重复]

This question already has an answer here:

I have a page [page A] that sends variable values to another page[page B]. Currently, I have been using the $_GET method to get the values from [page A] on [page B]. This is how the url in [page A] looks like

$id=2; <a href="pageB.php?id=$id">Goto Page B</a>

and on [Page B]

$id=$_GET['id'];
echo $id;

In this way I perfectly receive the value of the id from [page A] on [page B].

My questions is, would be possible to receive the value of the id from [page A] onto [page B] without adding ?id=$id to the url in [page A] ?

Please if yes, how can I do this. Thanks

</div>

You can use a $_SESSION variable, which will be available on every page once activated:

Page A:

<?php
    session_start();
    $_SESSION['id'] = 2;
?>

Page B:

<?php
    session_start();
    if (isset($_SESSION['id']))
        echo $_SESSION['id']; // 2
?>

you want to use sessions here:

session_start(); 
$_SESSION['id']= $id;

$id can of course be any value.