Jump to content

isLoggedIn() not working

Recommended Posts

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>';
    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.


It works fine on the pages that are pure PW, just not any that are Laravel driven.

Edited by MECU

Share this post

Link to post
Share on other sites

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

Share this post

Link to post
Share on other sites

use isLoggedin() lowercase ,,in,, not ,,In,,

und must have () after it


  • Like 2

Share this post

Link to post
Share on other sites

Although in the forum topic I did use the capitol I, in the code it is lower case i and has the ().

Share this post

Link to post
Share on other sites

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:


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 

Share this post

Link to post
Share on other sites

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:


//'Auth'            => 'Illuminate\Support\Facades\Auth',
//'Session'         => 'Illuminate\Support\Facades\Session',
There's also this:
But commenting that out caused Laraval to crash in wanting session help.

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By theoretic
      Hi there! And thanks for Processwire!
      I've got an interesting case concerning access to current user page. It appears that PW somehow limits access to the frontend page of current user.
      I'm speaking about a specific PW configuration. We have two kind of users: 'regular' users with native user template and member users with specific member template and specific members parent page (by the way, it's so cool that PW allows to use custom user templates and custom parent for certain user pages!). So a member with name Joe has a page with member template and url like /members/joe .
      The members template has some access limitations: only member users can see pages with member template. It works like a charm in most situations. For example, user Bill (who has member template and is logged in) can browse a page with url /members/ann which also is a member page with member template.
      And now, meet the glitch! The above-mentioned Bill cannot get to his own page /members/bill ! PW generates 404 page instead.
      I see no reason for this behavior. From my point of view any member should have access to any member page in this situation. What am i doing wrong? Any advice is welcome!
    • By VeiJari
      I'm trying to create a page via api and populate values to it. I can populate everything except user pages to a page reference array.
      $dataUsers = $data->project->users; foreach($dataUsers as $dataUser) { $newProject->projectUsers->add(wire()->pages->find('template=user, id=' . $dataUser->id)); } I'm receiving my data via JSON.
      Is there something I'm missing?
      Thanks for help
    • By neonwired
      I'm hoping someone has seen this before. There doesn't appear to be an issue with the user info.


    • By prestoav
      Hi there,
      I have a marketplace site that used the older Fredi module for front end editing so advertisers can create and edit their adverts (in the form of pages). After upgrading to v3.0 of Processwire I'd like to change the editing method for users to the new, core front end editing methods. However, it seems that with this method any editor can edit any page (subject to template restrictions for their user role). Using Fredi I checked the user and created user were equal before displaying edit buttons (clunky but it worked).
      Is there any stock way to restrict front end editing to the creator of the page so that my advertisers can only edit their own ads or should I test for user as before?
      Thanks in advance as always 🙂
    • By DooM
      Hey guys!
      I try to achieve a possibility for the client's admin account to change other users privileges. 
      In the CMS I have superadmin account, which is for me. My client got an account with a role user, which is limited administration account. The client also got some other people, who will edit the content with role editor  
      User story would look somehow like this:
      user role can add new roles and users user role can change privileges for all users (except superadmin). Eg. When the user role gives the editor role privilege to edit only articles. The Editor role will be able to edit only them.  
      I know this functionality is possible for superadmin, but I couldn't simulate it on the user role. Is there any easy way to achieve such a feature? Otherwise, I'll have to make a module for this I guess.
      Thanks for any help!
  • Create New...