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
EltonSky
Forum Newbie
Posts: 7 Joined: Tue May 02, 2006 7:47 pm
Post
by EltonSky » Wed May 24, 2006 7:50 am
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 » Wed May 24, 2006 8:27 am
Have you started the session using session_start()?
EltonSky
Forum Newbie
Posts: 7 Joined: Tue May 02, 2006 7:47 pm
Post
by EltonSky » Wed May 24, 2006 8:31 am
Yes I did.
Does any other possibility of this error?
GM
Forum Contributor
Posts: 365 Joined: Wed Apr 26, 2006 4:19 am
Location: Italy
Post
by GM » Wed May 24, 2006 8:37 am
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?
Bill H
DevNet Resident
Posts: 1136 Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:
Post
by Bill H » Wed May 24, 2006 9:47 am
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.