why i can not use &_SESSION

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
EltonSky
Forum Newbie
Posts: 7
Joined: Tue May 02, 2006 7:47 pm

why i can not use &_SESSION

Post 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
GM
Forum Contributor
Posts: 365
Joined: Wed Apr 26, 2006 4:19 am
Location: Italy

Post by GM »

Have you started the session using session_start()?
EltonSky
Forum Newbie
Posts: 7
Joined: Tue May 02, 2006 7:47 pm

Post by EltonSky »

Yes I did.

Does any other possibility of this error? :oops:
GM
Forum Contributor
Posts: 365
Joined: Wed Apr 26, 2006 4:19 am
Location: Italy

Post 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?
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Post 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.
Post Reply