Session Problem

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

magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

Which one's line 53 in login.php?
jrmontg
Forum Newbie
Posts: 12
Joined: Mon Apr 05, 2004 9:59 am

Post by jrmontg »

<?php echo "$errorMessage"; ?>
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

right. Now - look at that code on the previous page. See how $errorMessage is set after two separate if statements. If one of those fails then its not set. Obviously one is failing. I would guess the second, because we already fixed the first. Anyways, unless

<?php echo "$errorMessage"; ?>

has is not allowed to run unless $errorMessage is set, it will generate errors. So you have to either find out why $errorMessage is not getting set, or limit the above line to run only when errorMessage is set.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Similar Problem

Post by anjanesh »

Hello - Similar Problem
In a.php I have

Code: Select all

<?php
session_module_name("user");
session_set_save_handler("session_open","session_close","session_read","session_write","session_remove","session_gc");
session_start(); // Rest of the session fns are working including $PHPSESSID
$_SESSION['count']=5;
header("Location:b.php");
.
.
<session fns>
.
.
In b.php I have

Code: Select all

<?php
print($_SESSION['count']);
?>
This is what I get :
Notice: Undefined variable: _SESSION in b.php on line 1

register_globals = On. I'm using php4.3.4

Can anyone help me out here ?
Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you need session_start() in all files you wish to have access to the session variables.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Variable not declared

Post by anjanesh »

I did that too : session_start();
In that case it is showing that count is not declared
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

have you tried it without your custom session handlers? have you tried adding the session handlers to b.php? have you tried print_r($_SESSION), just to see what is declared?
yosuke_
Forum Commoner
Posts: 64
Joined: Tue Apr 13, 2004 12:29 pm

Post by yosuke_ »

Hi!
Well, I had (and still have) the same problem! I have that undefined index error on IIS and Apache! I can't understand why!!! :( I try everything, but nothing makes work sessions! I added session_start(); on each page, but after 3 pages it lost session data!! :cry:
Post Reply