Zen Cart Logo
Forums / Contribution-Writing Guidelines / setting $_SESSION variables in an Observer Class

setting $_SESSION variables in an Observer Class

Views: 2,180

Results 1 to 2 of 2
12 Feb 2013, 10:51 PM
#1
tcarden avatar

tcarden

Zen Follower

Join Date:
Oct 2012
Posts:
282
Plugin Contributions:
0

setting $_SESSION variables in an Observer Class

i tried initializing a $_SESSION variable in an observer class like this...

class hazMatProduct extends base {
var $_SESSION['hm-agreement'] = false;

but it throws an error. why does that create an error?,

the error log doesn't pick it up and record.

big thanks,

13 Feb 2013, 5:37 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: setting $_SESSION variables in an Observer Class

You can't use $_SESSION in class variable declarations. That's just a PHP rule.
You'll need to do that assignment in the constructor method instead.