23486 Posts in 18995 Topics by 2878 members
|Go to End|
8 May 2013 at 7:14am
Hi there, has the Session Mechanism changed in SS3.x?
On SS2.4 as I remember, Sessions (like Session::get('something')) where allready available in _config.php Files. In SS3.x this seems to have changed. Am I right? Is there any way to get Sessiion Variables back on _config files?
9 May 2013 at 3:58pm
Don't really know if the internal mechanics of Session have changed.
I can see the class in framework/control/Session.php
A quick test on a local SS3 install seemed to work in the mysite/_config.php file
die( Session::get('test') );
9 May 2013 at 5:59pm
You are right, that Example works.
But if you write a Session Variable somewhere else and try to read it from the _config File on the next request, it does'nt work.
I have changed the Project Folder to another one by setting these Variables inside mysite/_config.php
$project = 'cp_config';
Maybe that's the reason, why it doesn't work for me.
10 May 2013 at 7:40am
Hi there, try the following code and you will see, what I mean:
theoretically, after the second Page reload, the first and the second echo should output "val", but it doesn't.
10 May 2013 at 2:38pm
Will have a test after lunch. I wonder if the config file is read before the session object is found... I never know at which point the config file is read.
10 May 2013 at 5:24pm Last edited: 10 May 2013 5:49pm
Right... looks like Session::start isn't called before the loading of the _config file.
Short story this will work, echoing val twice
index.php is hit with a request which loads framework/main.php first thing that does is load core/Core.php which loads config and sets up DB connections. After that at the end of main.php Director::direct is called to load the relevant pages and starts the session, after config is loaded. So session will be initialised and usable in side PageController but not by default in _config.php.
|Go to Top|