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;
?>

Recommended Answers

All 4 Replies

thanks pritaeas:
but the problem still found.

<?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

it's working very well ,thank you very much (nav33n).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.