guly Posted January 10, 2015 Share Posted January 10, 2015 hello, i'm moving some code from 1.4 to 1.6. this specific module does things only for logged users, as far as i know this check changed a lot since 1.4. code examples that i've found around suggest to use isLoggedBack() call, present in employee context, and here i'm stuck. reducing code as soon as i can, i'm trying this: include_once("config/config.inc.php"); //yes, this exists if (Context::getContext()->employee->isLoggedBack()) { echo "is logged"; } else { echo "not logged"; } and all i've got is an error 500. i'm sure i miss something but i can't find what. could you please help me? thanks Link to comment Share on other sites More sharing options...
vekia Posted January 10, 2015 Share Posted January 10, 2015 code you mentioned is a part of main module .php file or some "external" file like controller? Link to comment Share on other sites More sharing options...
guly Posted January 10, 2015 Author Share Posted January 10, 2015 code you mentioned is a part of main module .php file or some "external" file like controller? it's an external file. Link to comment Share on other sites More sharing options...
vekia Posted January 10, 2015 Share Posted January 10, 2015 you included core files of shop, that are necessary to run Context class? i mean init php file and other important files Link to comment Share on other sites More sharing options...
vekia Posted January 10, 2015 Share Posted January 10, 2015 i mean init.php and config file Link to comment Share on other sites More sharing options...
guly Posted January 16, 2015 Author Share Posted January 16, 2015 you included core files of shop, that are necessary to run Context class? i mean init php file and other important files of course, the code is exactly what i pasted opening the topic. what's wierd is that if i do: if (Context::getContext()->customer->logged) { it works. i don't get why if (Context::getContext()->customer->logged) { works but if (Context::getContext()->employee->isLoggedBack()) { doesn't (i see the difference between customer and employee, but still i can't find the error here). Link to comment Share on other sites More sharing options...
Destiny84 Posted December 8, 2015 Share Posted December 8, 2015 I know this is an old topic but maybe someone comes here through Google like I did. The problem is that there is no employee object in the context when noone is logged in, so calling the function isLoggedBack() on a non-object throws the error. What works is this : if(!Context::getContext()->employee || !Context::getContext()->employee->isLoggedBack()) { echo 'not logged in'; } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now