Realmac Software

Welcome to the RapidWeaver Community Forums, where you can chat with RapidWeaver users from around the world!

Passing a parameter between PHP pages. Resolved - sorta...

David DelMonteDavid DelMonte Washington DC and Skopelos, Greece.Posts: 349Members
edited May 2010 in Tips, Tricks and How To's
I realized that I can write two javascripts to handle this.. Better ideas are welcomed...

1. Forgive all the PPPPPs.

I'm stumped. Is there a way to pass a parameter (cookie?) between two RW PHP pages?

page1 > sends the id number of a person..

page2 > reads the id number..

How do you add the cookie id to the page title?

Thanks!! It's time for a scotch...
<a href="http://www.bluehost.com/track/eclecktk5">I really enjoy using Bluehost,</a> and they will give me money if you sign up through this link!

Comments

  • Vasily IngoglyVasily Ingogly Naperville, Illinois, USAPosts: 2,579Moderators
    edited May 2010
    There are two ways to pass information between pages:

    1. Cookies, which exist (persist) between browser sessions
    2. Session variables, which go away after the browser session is done

    A cookie is used for example to hold login information so the visitor doesn't have to enter it every time he/she goes to the site. Session variables are preferable for transient data that's only needed for the current session. It's the need for persistence that determines whether you use one or the other.

    To use a session variable, put the following into Page Info]Header]Prefix for all pages that use the variable:
    &lt;?php session_start(); ?&gt;
    

    To set a session variable's value:
    $_SESSION['variablename'] = "abcd";
    

    To get a session variable's value:
    print $_SESSION['variablename'];
    

    or
    $localvar = $_SESSION['variablename'];
    print $localvar;
    

    To add the variable value to the title field, simply embed the PHP in the field as follows:
    This is the page title with the value &lt;?php print $_SESSION['variablename']; ?&gt; embedded in it
    

    The important thing to remember is you need to do the session_start before using any session variables. Cookies are not much more difficult to use. Without getting into details you can read about them here:

    http://www.w3schools.com/php/php_cookies.asp

    Vasily
    FYI - I no longer provide RapidWeaver solutions or any 1:1 support. My web design practice is focused 100% on web designs using WordPress.
    The High-Tech Coach
Sign In or Register to comment.