Session are not accessible in site.php (config file)

Permalink
Hello everyone,

When i try to access session from site.php of config the session are not available over there, So i tried to do session_start() from site.php but that is giving me error as below :

Fatal error: Concrete5_Model_PermissionAccess::validateAndFilterAccessEntities(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "GroupPermissionAccessEntity" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in /home/c2085051/public_html/updates/concrete5.6.0.2/concrete/core/models/permission/access/model.php on line 51

So what wrong i am doing here ? And what is the way with which i can access the session from site.php, please help to get me solution of it

View Replies: View Best Answer
JohntheFish replied on at Permalink Reply
JohntheFish
If your intention is to set up configuration information based on session info, a better way of doing it would be in an on_start event handler, where you already have $_SESSION and a basic c5 environment.
savan replied on at Permalink Reply
Hello JohntheFish,

Thanks for your reply.
I am trying for language change on the ecommerce checkout page , as my site is in multi language, so if user have danish selected then i want to keep danish on checkout pages but it dont works there. So i am trying that with session in site.php where i can set the language parameters but session are not accessible over there, So not sure how i will be able to do so. Please help to get me out of this.
Remo replied on at Permalink Reply
Remo
As John already wrote, I'd strongly advise not to do that kind of stuff in your config file. The internationalization add-on is what you'll need for this.

But nonetheless, the reason why you can't access the session is because the session in concrete5 has a name "CONCRETE5", you'd have to set that name first..
savan replied on at Permalink Reply
Hello Remo,

Thanks for your guide.
We the multilanguge package but that is not working for the pages that don't have language parameter in url. So it is not helping us on checkout pages, so i need to do with session. Is there any other way i can go with ?
Remo replied on at Permalink Reply
Remo
There's a fix for that somewhere in the forum. mlocati, mkly, me and a few others talked about that a while ago..

I currently can't find the discussion but I'll have another look later
Remo replied on at Permalink Reply
Remo
You can find more information in this thread (it's a long one): http://www.concrete5.org/marketplace/addons/internationalization/fo...
savan replied on at Permalink Reply
Thanks Remo,

I tried to set session name in config file still when i do session_start under it , it gives me error

Fatal error: Concrete5_Model_PermissionAccess::validateAndFilterAccessEntities(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "GroupPermissionAccessEntity" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in /home/c2085051/public_html/updates/concrete5.6.0.2/concrete/core/models/permission/access/model.php on line 101

is there any way i can solve it?
Remo replied on at Permalink Best Answer Reply
Remo
Well, I guess that's just the wrong way of doing it... I'd strongly advise to use the proper way to handle these things. The configuration file doesn't have access to the full c5 framework which is why you might get a ton more issues like that...

I'd focus on the internationalization add-on
savan replied on at Permalink Reply
Thanks,

I tried to find in forum i found below discussion :

http://www.concrete5.org/marketplace/addons/internationalization/fo...

In here also at lastly they have mentioned to use session and no final solution is there. So let me know if anything help me on it, as i am stuck here. Thanks for your all help.
Remo replied on at Permalink Reply
Remo
I'm not sure if it's a drop in solution, we have customized a lot in the core, but the code I've posted remember the last language in a session variable and thus translates pages like /login properly.

The method shown here might work in the controller of the internationlization add-on:

http://www.concrete5.org/marketplace/addons/internationalization/fo...

But as I said, it's possible that there's a dependency which the official core doesn't meet. But you should still be able to get the session part out of it..
savan replied on at Permalink Reply
Thanks Remo,

The link you gave from there i have placed the function in my package but that is not helping, tried to find other thing in that post but not sure if anything else i need to further to make it working.
JohntheFish replied on at Permalink Reply
JohntheFish
Not a solution, but for diagnostics the free 'Quick Param View' addon block can be used to dump $_SESSION straight onto a page.
savan replied on at Permalink Reply
Hmm is there any need to change the dispatcher and put the confing/localization like after config/startup ? (but as that file can not be override not sure)
savan replied on at Permalink Reply
hello Remo,John

John not sure for your reply i am not able to get it.

I have tried with many thing , you are right we can ignore the coding from site.php , but still i need to change in core files that is either config file localization.php or dispatcher.php ( which cant not be over ride outsite). In that when the c5 updated the changes are gone.

For now i do changes are in

(config/)localization.php(by commeting active_locale from here) / dispatcher.php (Or by moving localization line after package)(any of one)
library/localization.php => access session from here.
config/site_theme_paths.php => making session here.

So can you help me find the prominant solution for it.

Thanks