0

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?

2
  • 3
    Do you have session_start() in your first page? If not, your session isn't established and your variable will be lost. Commented Oct 28, 2013 at 7:10
  • Do print_r($_SESSION) and temme what is your output.. Commented Oct 28, 2013 at 7:15

2 Answers 2

1

Try these:

Page1.php:

<?php

...
session_start(); 
$_SESSION["UID"] = $row["JS_ID"];
...

?>

Page2.php:

<?php

...
session_start(); 
$uid=$_SESSION["UID"];
...

?>
Sign up to request clarification or add additional context in comments.

Comments

1

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.

1 Comment

And remove the session_start on second page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.