Zen Cart Logo
Forums / Contribution-Writing Guidelines / A pretty weird problem while accessing session outside of zen

A pretty weird problem while accessing session outside of zen

Locked

Views: 3,403

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
11 Jan 2009, 5:28 PM
#1
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

A pretty weird problem while accessing session outside of zen

I'm trying to access $_SESSION outside of zen, the purpose is to set a certain variable to see if js is enabled or not (the file is placed at zen root folder and called via ajax)

    require('includes/application_top.php');
    
    sleep(5);
    
    $_SESSION['javascript_enabled'] = true;
    
    exit();

You can notice I have to use sleep(5), otherwise the session is still set (when I print_r), but it's not stored at all (when you go to the next page)

I suspect we have a race condition here? It's weird since I thought php can not work that way.

25 May 2009, 3:42 AM
#2
dermanomann avatar

dermanomann

New Zenner

Join Date:
Feb 2006
Location:
New Zealand
Posts:
146
Plugin Contributions:
1

Re: A pretty weird problem while accessing session outside of zen

I would assume it is because application_bottom.php is not included. That, in turn, would call session_close (or similar). My understanding is that that will trigger persisting the session.

mano

1 Jul 2009, 1:44 AM
#3
teedave avatar

teedave

New Zenner

Join Date:
Feb 2007
Posts:
3
Plugin Contributions:
0

Re: A pretty weird problem while accessing session outside of zen

Thanks mano, i've been bashing my head against the wall about this for a long time.
If you ever in wgtn, I'll buy you a beer/coffee/preferred liquid refreshment.
Cheers
Dave T