Jump to content

Passing variables from one page to the next


oracle259

Recommended Posts

Use sessions.
You must have [code]session_start();[/code] at the top of the page you want to define or call sessions or you will get some nice errors...

Then, simply register assign your session to a variable. Eg :
[code]
<?
session_start();
$name="Olly";

session_register('name');
$_SESSION['name'] = $name;
?>
[/code]

Then you can use the value assigned to $name on any page by calling [code]$_SESSION('name');[/code] eg,

[code]
<?
session_start();

echo "Name:" . $_SESSION['name'];

// Prints:
// Name: Olly
?>
[/code]
lowe_22:

I just recently discovered, dont recommend register_session() as this function wont be supported on systems without register_globals, and in version 6, wont be supported at all.

Instead recommend:

<?

session_start();
$name="Olly";
$_SESSION['name'] = $name;

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.