Addpixel / KirbyComments

[Kirby 2] File-based comments stored as subpages for the Kirby CMS.
MIT License
68 stars 5 forks source link

side effects if session_start() in comments.php #15

Closed gerritvanaaken closed 7 years ago

gerritvanaaken commented 7 years ago

In my template file I check if a user is logged, like this:

<?php if ($site->user() && $site->user()->role() == 'admin' ): ?>
  Hallo Admin!
<?php endif ?>

If do this before the comments include, I get the following error: bildschirmfoto 2017-02-27 um 23 07 56

If I do it after including the comments, the $site->user() is always false, even when I’m properly logged in. Can you do something about it?

florianpircher commented 7 years ago

Looks like line 103 in plugin/comments.php should be replaced by:

if (session_status() == PHP_SESSION_NONE) {
    session_start();
}

I will include this in the next release.

florianpircher commented 7 years ago

This has been fixed by v1.2.2.