-
☆ A M B ☆
- 24,524 Posts
Hmm... trying it I get a 0, then it adds 2 with each page load. I did change the snippet code to output the results instead of echo it, but it's still increasing by 2.
<?php
if(!isset($_SESSION['headerphotonum'])) { $_SESSION['headerphotonum']=-1; }
return $_SESSION['headerphotonum']++;
[ed. note: sottwell last edited this post 12 years, 6 months ago.]
Some Google tools or the like will make a request to the same page after each legitimate request.
-
☆ A M B ☆
- 24,524 Posts
I'm just using a fairly new installation on Localhost with nothing but TinyMCE, pdoTools and Ace installed.
-
☆ A M B ☆
- 24,524 Posts
Ok... something very fishy is going on. On my MODX Cloud installation, it works just fine. So why is it loading twice on my localhost MAMP installation?
-
☆ A M B ☆
- 24,524 Posts
On further investigation, if the page is unpublished it increments by one as expected, when viewed by a logged-in Manager user. On a published page, not logged in at all, it again increments by one as expected. So MODX is doing something odd with the SESSION when logged in.
Well, that still doesn't explain why it isn't incrementing by 2 on the Cloud, logged in or not, published or not...
Put it in the template on the Cloud instead of in a resource, and now it's incrementing by 2. This is really weird.
[ed. note: sottwell last edited this post 12 years, 6 months ago.]
And it's not making any difference for me if I'm logged in or not. I also tried converting the script from static to non-static, and that didn't do anything. The other weird thing is that it's not regular; I've had the number increase by anywhere from 4 to 15 in no particular sequence.
_______________________________
OK, I just turned off "session_enabled" and put session_start() in my header. No luck. On first refresh it went up by 4. On second refresh it went up by 25!!
[ed. note: rainbowtiger last edited this post 12 years, 6 months ago.]
The only thing I can think of to do at this point is to put a time check in there: only increment the number if more than 2 seconds have passed.
-
☆ A M B ☆
- 24,524 Posts
Is it possible that the SESSION is being hit with every request for images, js scripts, etc?