将url变量传递到下一页?

I need some help on passing a url php variable onto the next page. I've tried searching throughout the site for help and I've spent a lot of time trying to figure this out with no luck. Basically I need to be able to change the paypal link button id on page 2 with the url variable from page 1.

The variable is initially passed along with the URL: http://www.example.com?p=paypalbuttonid I would like to store and pass that "p" variable on to the next page. I don't want to pass the variable onto page 2 with a link. I would prefer to store the variable and recall it on page 2.

Page 1 code (above html):

<?php
    session_start();
    $_SESSION['paypal'] = $_GET['p'];
?>

Page 2 code (above html):

<?php
    session_start();
    $p = $_SESSION['paypal'];
?>

I'm calling the variable in a link on page 2 (body):

<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=<?php echo $p ;?>" target="_blank" class="btn">

I'm not sure what I'm dong wrong but I'm a complete newbie to PHP so please help! The variable shows up blank in the URL on page 2. Thank you! - Chad

First, you should make sure you dont have any output before session_start(), it is safe to put session_start () at the top of the page , especially if you use php code in .html, since you may have output without awareness, and session wont work if you have anything output to the browser before session_start()

according to php.net:

To use cookie-based sessions, session_start() must be called before outputing anything to the browser.

and you should check if you cookie is enabled.

Secondly, var_dump ($_SESSION); to see if you can get anything