0

i want to send variable from one page to other in php and iam using session, but the variable doesn't appear in other page. iam using this code :

page 1:
<?php
session_register('number');
$number =10;
header("Location: page2.php");
?>

page 2:
<?php
echo"number= ".$number;
?>

3
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by almualim
0
<?php
//page1.php
session_start();
$_SESSION['number'] = 10;
header("Location: page2.php");
?>

and

<?php
//page2.php
session_start();
echo"number= ".$_SESSION['number'];
?>

If you want your script to work regardless of register_globals, you need to instead use the $_SESSION array as $_SESSION entries are automatically registered. If your script uses session_register(), it will not work in environments where the PHP directive register_globals is disabled.

Source : http://nl2.php.net/manual/en/function.session-register.php

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.