Sunday, 15 September 2013

accessing session variable in second php page

accessing session variable in second php page

my first php file is basic.php
session_start();
?>
<html>
<body>
<a href="basic2.php? name=qadeerhussain"> click on it</a>
<?php
$_session['username']="qadeerhussain";
print $_session['username'];
?>
</body>
</html>
out put of basic.php is: click on it qadeerhussain my second basic2.php
page is
<?php
session_start();
?>
<html>
<body>
<?php
print $_SESSION['username'];
?>
</body>
</html>
but it give me the following exception... Notice: Undefined index:
username in C:\wamp\www\test\basic2.php on line 12

No comments:

Post a Comment