Page 1 of 1

why i can not use &_SESSION

Posted: Wed May 24, 2006 7:50 am
by EltonSky
Hello there,

I assign some value to $_SESSION in a page like:

Code: Select all

$quan = $_POST['quantity'];
  $_SESSION['quantity'] = $quan;
and i try to call $_SESSION['quantity'] in a following page, but it's always empty.
i can echo $_SESSION['quantity'] in the prev page.

HELP~~~~


THANX,

Elton

Posted: Wed May 24, 2006 8:27 am
by GM
Have you started the session using session_start()?

Posted: Wed May 24, 2006 8:31 am
by EltonSky
Yes I did.

Does any other possibility of this error? :oops:

Posted: Wed May 24, 2006 8:37 am
by GM
Try putting session_write_close() at the bottom of your scripts - it could be that you are doing a redirect before the session variable is written?

Posted: Wed May 24, 2006 9:47 am
by Bill H
Try using different index names for the global arrays.
instead of

Code: Select all

$quan = $_POST['quantity'];
  $_SESSION['quantity'] = $quan;
Something like

Code: Select all

$quan = $_POST['pquan'];
  $_SESSION['squan'] = $quan;
It's my experiance that the two global arrays sort of "bleed" into each other at times.

Local variables with the same names as gobal array index names can cause problems as well.