[support] $_SESSION Variables in drupal 7

Metzler, David metzlerd at evergreen.edu
Fri Sep 23 16:58:20 UTC 2011


The error is most likely cuased by accessing the $_SESSION variable, not
setting it.  Look for places in your code where test for something like:


$_SESSION['foo']

In if the index 'foo' for the session variable has not been set then you
will get this error, because drupal 7 reports notices as well as
warnings.   

Depending on the situation you may want to recode like this: 

if (isset($_SESSION['foo']) 

Or like this: 

@$SESSION['foo']

The @ operator will suppress errors and warnings in the site for that
atomic command.  The isset will test whether the index is set without
throwing the notice to begin with. 

 

-----Original Message-----
From: support-bounces at drupal.org [mailto:support-bounces at drupal.org] On
Behalf Of Mutuku Ndeti
Sent: Friday, September 23, 2011 2:44 AM
To: support
Subject: [support] $_SESSION Variables in drupal 7

Hi,

I am working on porting a module to d7.

I am getting an error "Notice: Undefined index: VARIABLE NAME
in.........

I have searched the internet and tried using drupal_set_session but I
am still getting the same error.

 I am using D7.8




-- 
Tel:254- 722-490994
www.agile.co.ke | www.jipambe.com
-- 
[ Drupal support list | http://lists.drupal.org/ ]


More information about the support mailing list