MECU Posted March 28, 2014 Share Posted March 28, 2014 (edited) I'm incorporating PW into a Laravel site layout. For the Login/Logout links, I have: <?php if ( !wire('user')->isGuest() && wire('user')->id && wire("user")->isLoggedin() ) { echo '<li><a href="/pages/control/">Admin</li> <li><a href="/pages/control/login/logout/">Logout</li>'; } else echo '<li><a href="/pages/control/login/">Login</li>'; ?> I started with just wire('user')->isLoggedin(), and that didn't seem to work, so searching around the forums added in the other items. Basically, whether I'm logged in or not, I always see a Login link. If I dd/datadump (a Laravel function) the wire('user') I get what looks like the PW user class. So I've included the PW index.php correctly into my Laravel bootstrap/start.php. As an aside, $wire->user->isLoggedIn() doesn't work. It's probably some conflict with Laravel. Switching to use wire('user')->isLoggedIn() let me work, though it gives the wrong result. EDIT 1: It works fine on the pages that are pure PW, just not any that are Laravel driven. Edited March 28, 2014 by MECU Link to comment Share on other sites More sharing options...
Macrura Posted March 29, 2014 Share Posted March 29, 2014 the only time i had an issue with isLoggedin was when logging in to the admin by accident on a non-www and viewing the site on www Link to comment Share on other sites More sharing options...
MECU Posted March 29, 2014 Author Share Posted March 29, 2014 I am solely using non-www on the site. Link to comment Share on other sites More sharing options...
WillyC Posted March 29, 2014 Share Posted March 29, 2014 use isLoggedin() lowercase ,,in,, not ,,In,, und must have () after it u.will 2 Link to comment Share on other sites More sharing options...
MECU Posted March 30, 2014 Author Share Posted March 30, 2014 Although in the forum topic I did use the capitol I, in the code it is lower case i and has the (). Link to comment Share on other sites More sharing options...
MECU Posted April 1, 2014 Author Share Posted April 1, 2014 It seems I've included ProcessWire correctly, as I can access the API, but the fact that I'm logged is does not register correctly. According to the Include & Bootstrap page, all I need to do is include this in Laravel and I'm done: require($app['path.base'].'/public/pages/index.php'); It seems I need to actually process whether a user is logged in? Does the fact that I have it installed in a /pages subdirectory matter? I deleted all cookies and tried again and it didn't matter. The cookies don't have a directory Link to comment Share on other sites More sharing options...
MECU Posted April 2, 2014 Author Share Posted April 2, 2014 Turns out it was a collision between Laravel and PW sessions. Once I removed the Laravel Session provider and alias in /laravel/app/config/app.php it worked great. I also removed the Auth provider and alias. Not sure if that is also needed to be removed with Session. I didn't test enough to determine that. If the above alone doesn't work, then also remove the Auth and it should work. Here's everything I commented out to get it to work: //'Illuminate\Auth\AuthServiceProvider', //'Illuminate\Session\CommandsServiceProvider', //'Auth' => 'Illuminate\Support\Facades\Auth', //'Session' => 'Illuminate\Support\Facades\Session', There's also this: 'Illuminate\Session\SessionServiceProvider', But commenting that out caused Laraval to crash in wanting session help. 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