Quote:
Originally Posted by coolsti
This should work better for you.
-
<?php
-
-
session_start();
-
$pid = $_GET['id'];
-
$_SESSION["pid"] = $pid;
-
-
?>
-
Unless you have a very old php installation, the above should work instead of the code you presented. This starts the session, then puts the value for the id in a PHP variable $pid, and in the next line, it creates a session variable (by adding an element to the $_SESSION array) with key "pid" and sets it to the value of the id stored in $pid. Note that these two lines can be combined, to $_SESSION["pid"] = $_GET['id'] without needing to use the intermediate variable $pid.
You may want to call trim() on the value of id first, to get rid of any leading or trailing spaces in case they occur.
Note that you also need to call session_start() in any later pages that wish to access the value of $_SESSION["pid"].
Hey thanks so much for your answer. but even this way i keep loosing the value when I navigate to another page and back from abc.php.
Well im thinkin may be cookies is the solution
like:
setcookie("cookname", $_SESSION["pid"], time()+60*60*24*100, "/");
if there's someother way smone pls let me know. thanks in advance!!
See what I want is to have a constant value for 'id' throughout my PHP pages.
I want the value for 'id' to be consistent throughout my pages (until the user selects another id)