# Recalling Session Variables throughout site

**URL:** <https://forum.kirupa.com/t/recalling-session-variables-throughout-site/303655>\
**Category:** programming\
**Created:** [January 24, 2010, 12:50pm UTC](https://forum.kirupa.com/t/recalling-session-variables-throughout-site/303655 "2010-01-24T12:50:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![oddball](https://avatars.discourse-cdn.com/v4/letter/o/34f0e0/32.png) [@oddball](https://forum.kirupa.com/u/oddball)\
**Post date:** [January 24, 2010, 12:50pm UTC](https://forum.kirupa.com/t/recalling-session-variables-throughout-site/303655/1 "2010-01-24T12:50:50Z")

</div>

Hey

I cannot seem to recall my session variables throughout my site and i cannot see where i am going wrong.

I have variables in my flash file which i have posted into my ‘info.php’ all working fine, i declare the post variables in ‘info.php’ with the following:

```auto
**$num** = $_POST['number'];
    **$choice** = $_POST['choice'];
    **$colour** = $_POST['colour'];

```

These variables then get called in a simple form that is echo’d as below:

```auto
echo '<div id="info">
    <form name="form" method="post" action="">
    <table width="450" border="0" cellspacing="1" cellpadding="3">
    <tr><td width="65%"><strong>Number</strong></td>
    <td width="65%"><strong>Choice</strong></td>
    <td width="20%"><strong>Colour</strong></td>
    <td width="15%"><strong>Quantity</strong></td></tr>
    <tr><td> **'.$num.'** </td><td> **'.$choice.'** </td><td><input type="text" name="colour" value=" **'.$colour.'**"readonly></td>
    <td><input type="text" name="qty1" size="5" value="1"> </td></tr>
    <tr valign="bottom"><td><br>Paying with: <br>
    <input type="radio" name="x" value="CashPayment" checked="checked">Cash<br>
    <input type="radio" name="x" value="CardPayment">Card</td>
    <input type="submit" name="Submit" value="Submit"></td></tr>
    </table>
    </form>';

```

I then set the post variables to session variables with the following:

```auto
$num = $_POST['number'];
    $choice = $_POST['choice'];
    $colour = $_POST['colour'];
        **$_SESSION['num']** = $_POST['number'];
    **$_SESSION['choice']** = $_POST['choice'];
    **$_SESSION['colour']** = $_POST['colour'];

```

So the form has the session variables stated as in:

```auto
echo '<div id="info">
    <form name="form" method="post" action="">
    <table width="450" border="0" cellspacing="1" cellpadding="3">
    <tr><td width="65%"><strong>Number</strong></td>
    <td width="65%"><strong>Choice</strong></td>
    <td width="20%"><strong>Colour</strong></td>
    <td width="15%"><strong>Quantity</strong></td></tr>
    <tr><td>**'. $_SESSION['num'].'**</td><td>**'. $_SESSION['choice'].'**</td><td><input type="text" name="colour" value="**'. $_SESSION['colour'].'**"readonly></td>
    <td><input type="text" name="qty1" size="5" value="1"> </td></tr>
    <tr valign="bottom"><td><br>Paying with: <br>
    <input type="radio" name="x" value="CashPayment" checked="checked">Cash<br>
    <input type="radio" name="x" value="CardPayment">Card</td>
    <input type="submit" name="Submit" value="Submit"></td></tr>
    </table>
    </form>';

```

I have

```auto
<?php
session_start();

```

At the top of every php page.

Can anyone help me with what i am doing wrong? The variables display when you first go to ‘info.php’ but as soon as you navigate away and then back the fields are empty.

Any ideas?

Many thanks

Jon
