If this is your first visit, check our documentation. To post, register or login.
Forums / Community Contributed Add-Ons / Contribution-Writing Guidelines / setting $_SESSION variables in an Observer Class

setting $_SESSION variables in an Observer Class

Started by tcarden on 12 Feb 2013, 10:51 PM · Views: 2,200

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

Post #1 by tcarden

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,512
Plugin Contributions:
176

Post #2 by drbyte

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.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.