Undefined index:

This is a discussion on Undefined index: within the PHP General forums, part of the PHP Programming Forums category; I'm using this code to check if a cookie has a value : If(!IsSet($HTTP_COOKIE_VARS["LoggedIn"])) .... In ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-16-2007
WeberSites LTD
 
Posts: n/a
Default Undefined index:

I'm using this code to check if a cookie has a value :

If(!IsSet($HTTP_COOKIE_VARS["LoggedIn"])) ....


In case that this cookie is not set, how can i avoid the
Undefined index: line in the error log?

berber

Reply With Quote
  #2 (permalink)  
Old 06-16-2007
tedd
 
Posts: n/a
Default Re: [PHP] Undefined index:

At 2:37 PM +0200 6/16/07, WeberSites LTD wrote:
>I'm using this code to check if a cookie has a value :
>
> If(!IsSet($HTTP_COOKIE_VARS["LoggedIn"])) ....
>
>
>In case that this cookie is not set, how can i avoid the
>Undefined index: line in the error log?
>
>berber


berber:

Try this:

$loggedIn = isset($HTTP_COOKIE_VARS["LoggedIn"]) ?
($HTTP_COOKIE_VARS["LoggedIn"]) : "not logged in";
echo($loggedIn);

Cheers,

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
Reply With Quote
  #3 (permalink)  
Old 06-16-2007
Stut
 
Posts: n/a
Default Re: [PHP] Undefined index:

WeberSites LTD wrote:
> I'm using this code to check if a cookie has a value :
>
> If(!IsSet($HTTP_COOKIE_VARS["LoggedIn"])) ....
>
>
> In case that this cookie is not set, how can i avoid the
> Undefined index: line in the error log?


The isset function does not give an error if you pass it a non-existant
variable. Are you sure it's this line that's causing the undefined index
error?

-Stut
Reply With Quote
  #4 (permalink)  
Old 06-16-2007
Al
 
Posts: n/a
Default Re: Undefined index:

There is obviously something else wrong. That's the purpose of isset();

Comment out your line and see what happens.

I'd guess the real problem is later in your code when you are trying to do
something with $HTTP_COOKIE_VARS["LoggedIn"] even though your isset() test said
it didn't exist.

WeberSites LTD wrote:
> I'm using this code to check if a cookie has a value :
>
> If(!IsSet($HTTP_COOKIE_VARS["LoggedIn"])) ....
>
>
> In case that this cookie is not set, how can i avoid the
> Undefined index: line in the error log?
>
> berber
>

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:08 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0