Reputation: 512
I stored a value of id in first php page as,
<?php
...
$_SESSION["UID"] = $row["JS_ID"];
...
?>
this is the 2nd page,
<?php
...
session_start();
$uid=$_SESSION["UID"];
...
?>
when am passing it as value it works,,but when I'm running my project, it's saying error as, "Undefined index UID"..Is there any way to clear it out?
Upvotes: 0
Views: 62
Reputation: 5402
Try these:
Page1.php:
<?php
...
session_start();
$_SESSION["UID"] = $row["JS_ID"];
...
?>
Page2.php:
<?php
...
session_start();
$uid=$_SESSION["UID"];
...
?>
Upvotes: 1
Reputation: 28763
First you need to remove the session start from second page and start the session on that first page with
session_start();
Because whenever you have started the session then only you can access the session variables.But You are starting the session on the second page.Which has no use.
Upvotes: 1