Oli1
                
              
                
              
                  
                  
              1
              
             
            
              Hi there,
I have a dead simple Hitcounter at each Page:
$page->increment('hitcounter');
But since Kirby 3 this isn’t working anymore expect I’m logged in. Seems like there’s something with the Permissions wrong?
Kirby \ Exception \ PermissionException (error.page.update.permission)
You are not allowed to update "xxx"
             
            
              
              
              
            
            
           
          
            
            
              Your answer can be found here https://getkirby.com/docs/guide/content/pages#creating-pages-programmatically (just for future reference).
To update a page you need the right permissions - and using ->increment() is updating the page, it’s just a shorthand.
One way to go without authentication is to impersonate the special kirby super user, which has full permissions:
<?php
$kirby = kirby();
$kirby->impersonate('kirby');
$page->increment('hitcounter');
             
            
              
              
              1 Like
            
            
           
          
            
              
                Oli1
                
              
              
                  
                  
              3
              
             
            
              Thanks a lot. I have a Query like this:
if ( $site->user() ) {
  echo 'YES USER';
}
Now this returns always the true value if I impersonate Kirby user, no matter if I’m really a logged in user. Any other solution maybe?
             
            
              
              
              
            
            
           
          
            
            
              And you $page->increment('hitcounter'); call is happening inside of this if-statement?
             
            
              
              
              
            
            
           
          
            
              
                Oli1
                
              
              
                  
                  
              5
              
             
            
              Not really but I use the above state to control some CSS and appearance options. Now they are always visible …
             
            
              
              
              
            
            
           
          
            
            
              Should be $kirby->user() not $site->user(), that has changed from K2 => K3.
             
            
              
              
              1 Like
            
            
           
          
            
              
                Oli1
                
              
              
                  
                  
              7
              
             
            
              Thanks, this seems to work 
             
            
              
              
              
            
            
           
          
            
            
              Thanks for spotting this, @texnixe. Was already on the path down to un-impresonate.