/    Sign up×
Community /Pin to ProfileBookmark

variable frustration

Forgive me asking such simple questions but I’m a bit confused.
On my index.php page I have this:

<?php
session_start();
$_SESSION[‘isadmin’] = ‘NO’;
?>

On a member login page I have this:

<?php
$flag = $_SESSION[‘isadmin’];
if ($flag == ‘YES’){
echo $flag;
}
?>

When I run it I get:

PHP Notice: Undefined variable: _SESSION in c:Inetpubwwwrootmemberlogin.php on line 67

Can someone explain why it is flagging _SESSION as an undefined variable?

Thanks,
Rut

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogDec 14.2005 — You need a session_start() on any page that is going to interact with the $_SESSION array.
Copy linkTweet thisAlerts:
@rutledjauthorDec 14.2005 — So you have to put it on every page? I thought it was a one time thing!
Copy linkTweet thisAlerts:
@NogDogDec 14.2005 — Yeah, the name sort of sounds like it's just used to "start" the session, but it means to start session processing for the currently running script.
Copy linkTweet thisAlerts:
@SheldonDec 14.2005 — and dont forget that it needs to be at the top of the page with no gaps before the <?php part.
×

Success!

Help @rutledj spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...