Posts: 53
Threads: 11
Joined: Mar 2015
2018-03-06, 19:17:30
(This post was last modified: 2018-03-06, 19:19:23 by vanfruniken.)
In an attempt to avoid repeatedly finding out Server/Client's IP/DNS and querying external sites for GeoIp info, I am trying to collect this info once and for all and pass it along to further pages via the SESSION variable using $_SESSION['myKey'].
I initiate the creation (or check for existence/home-brew timeout) of my session data quite early, namely from hook_theme-header.
The $_SESSION variable already exists and session_start() has already been called (I get a warning to that effect when I call session_start) (Why? If I understand correctly, Shawn claims GetSimple isn't relying on Session vars).
Unfortunately I have run into server memory overflows, and I am just asking myself whether it is acceptable to do a session_unset() . Will the internal operation of GetSimple be disrupted? I suspect not.
Any suggestions? Am I barking up against the wrong tree with my approach?
Posts: 6,266
Threads: 181
Joined: Sep 2011
Gs doesnt use sessions although some plugins do
Posts: 3,491
Threads: 106
Joined: Mar 2010
What if you use the index-pretemplate hook?
Posts: 6,266
Threads: 181
Joined: Sep 2011
Did you check whats in the session? Maybe php auto sessions ?
Posts: 53
Threads: 11
Joined: Mar 2015
(2018-03-07, 02:31:17)shawn_a Wrote: Did you check whats in the session? Maybe php auto sessions ?
What I see in the $_SESSION variable is not much
Don't know about "cat", but "p01contact" comes from a plugin that's installed.
"fvVar" is my associative array, which I create.
{ "cat":null,
"p01contact":{"pageloads":[1520354514,1520354516]},
"fvVar":{
"ipDns": { "server":{"ip":"8.7.6.5","dns":"do.main.be"}, "client":{"ip":"11.22.33.44","dns":"dom.ain.be"} }
"geoIp": { ... },
"expirationTime": 123...45
} }
At some point, I struggled with excessive memory usage: hundreds of MBs, overflowing the server limit and slowing down the pages, but with some cleaner programming, it remains stable at 5MB. Don't know why exactly it is better now. I didn't need to use session_start().
Posts: 538
Threads: 12
Joined: May 2013
2018-03-07, 20:39:32
(This post was last modified: 2018-03-07, 20:40:16 by Bigin.)
A good practice is to check session status before you call session_start:
PHP5.4+
PHP Code:
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
Posts: 6,266
Threads: 181
Joined: Sep 2011
What version of php? I remember having to do something similar because of a sesison bug
Posts: 53
Threads: 11
Joined: Mar 2015
2018-03-08, 19:47:04
(This post was last modified: 2018-03-08, 21:29:20 by vanfruniken.)
My isp uses Php 5.6.31, with session.auto_start off.
At hook_theme-header time, session_start() has already been called, headers_sent().
Occasionally, though, the /GS/ subsite grinds to a halt, including sometimes /GS/admin, while the production site at '/' still remains responsive as usual. I see no php memory increase while /GS is still working, but haven't been able to inspect that when these pages are blocked.
Restarting my browser sometimes helps. Waiting a few minutes too.
I've been reading around about (and half-understanding) the server-side file backup of $_SESSION being locked and header sizes getting out of hand. I suppose trying session_write_close() is a bit harsh w.r.t. plugin compatibility and may not address the problem anyway.
Thanks for your suggestions.