p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Beginning PHP (http://p2p.wrox.com/forumdisplay.php?f=95)
-   -   my session variables not retaining values (http://p2p.wrox.com/showthread.php?t=44271)

nidhimittal June 21st, 2006 12:30 AM

my session variables not retaining values
 
  hi all
i have been trying to use session variables but getting no results
my site is multipage and from first page i am storing value in session variable and retrieving it back in other pages but no variable retains its value in other pages
what i did was
if

register global=Off (directive in php.ini)

$page=$_GET["page"];

/*for all other pages*/
if($page > 1)
{
session_start();
 $emp_nos = $_SESSION['MyEmpNos'];

}
else
{/*in my first page*/

  session_start();
  $_SESSION['MyEmpNos'] = $emp_nos;

}

but i am not getting MyEmpNos value retained in further pages

i tried even with
 register global= On (directive in php.ini)
and
used

session_start();
session_register();

 also

but no results then too in variable $_SESSION["MyEmpNos"];
can somebody please help.................i need it urgently ..

nidhi

guillermo June 21st, 2006 11:23 AM

this code is a little hard to understand...

if ($page > 1) ... are you using negative values? When is '$page' ever less than 1? Could you post more of the code? As it is, I can't understand the logic... and, on another note & just out of curiosity, why are you placing your comments after the code for which they are meant?

nidhimittal June 22nd, 2006 12:40 AM

hi
no $page can have in my case NULL or zero value also .
but i have got the solution thanks .
and comments i put for easy understanding of code .
b bye
nidhi

nidhi

Dnigma June 23rd, 2006 05:26 AM

the problem is:
register global=Off (directive in php.ini)

To make use of $_SESSION and other variables of similar nature, registered globals must be on.

Have fun,
Dale


Ctrl-Alt-Del

nidhimittal July 7th, 2006 12:33 AM

no sorry you are absolutely wrong
$_SESSION[] array can be used in both cases whether register global is on or off
but the only thing is
if it is ON
we cant use $page directly


nidhi


All times are GMT -4. The time now is 04:43 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.