pixelbart/helpful

headers already sent

Closed this issue · 7 comments

Warning: Cannot modify header information - headers already sent in /var/www/zerozone.it/www/wp-content/plugins/helpful/core/helpers/class-user.php on line 101

You can disable sessions in Helpful's settings if other plugins already set them somehow before. The problem here is that something is executed before the execution of add_action('init'), which leads to problems. So the problem here is not with Helpful, but with something else.

I have a lot of the same warnings in error log file

[10-Aug-2021 04:57:36 UTC] PHP Warning:  Cannot modify header information - headers already sent in /var/www/vhosts/xxx.com/httpdocs/wp-content/plugins/helpful/core/helpers/class-user.php on line 101
[10-Aug-2021 04:57:36 UTC] PHP Warning:  session_cache_limiter(): Cannot change cache limiter when headers already sent in /var/www/vhosts/xxx.com/httpdocs/wp-content/plugins/helpful/core/helpers/class-user.php on line 123
[10-Aug-2021 04:57:36 UTC] PHP Warning:  Cannot modify header information - headers already sent in /var/www/vhosts/xxx.com/httpdocs/wp-content/plugins/helpful/core/helpers/class-user.php on line 124
[10-Aug-2021 04:57:36 UTC] PHP Warning:  session_start(): Cannot start session when headers already sent in /var/www/vhosts/xxx.com/httpdocs/wp-content/plugins/helpful/core/helpers/class-user.php on line 125

I have a lot of the same warnings in error log file

[10-Aug-2021 04:57:36 UTC] PHP Warning:  Cannot modify header information - headers already sent in /var/www/vhosts/xxx.com/httpdocs/wp-content/plugins/helpful/core/helpers/class-user.php on line 101
[10-Aug-2021 04:57:36 UTC] PHP Warning:  session_cache_limiter(): Cannot change cache limiter when headers already sent in /var/www/vhosts/xxx.com/httpdocs/wp-content/plugins/helpful/core/helpers/class-user.php on line 123
[10-Aug-2021 04:57:36 UTC] PHP Warning:  Cannot modify header information - headers already sent in /var/www/vhosts/xxx.com/httpdocs/wp-content/plugins/helpful/core/helpers/class-user.php on line 124
[10-Aug-2021 04:57:36 UTC] PHP Warning:  session_start(): Cannot start session when headers already sent in /var/www/vhosts/xxx.com/httpdocs/wp-content/plugins/helpful/core/helpers/class-user.php on line 125

The error caused by Helpful has already been fixed. If the header is set before, then not by Helpful. Here something is output incorrectly somewhere else.

Helpful uses: add_action('init', [ & $this, 'set_user_cookie'], 1);

Rel: https://github.com/pixelbart/helpful/blob/master/core/modules/class-core.php#L50

I understand you but debug.log showing helpful plugin warnings, I think you can temporary fix it and its better if you add a checker before sending headers, We have a lot of visitors daily and our debug.log file is full of helpful plugin warning related to sessions.

@Codevz

Helpful already checks if the sessions are set. The error appears only if something is executed or output (in the DOM) before the sessions are set. Otherwise the error would not appear.

If you have a code suggestion, or a useful improvement suggestion for the method, feel free to share it. I am open for everything!

See: https://github.com/pixelbart/helpful/blob/master/core/helpers/class-user.php#L67

Should be fixed, so I'll close here for now.

helpful/core/modules/class-core.php on line 89, the user cookie is being set on the init hook. Doing this causes the following exception: “Cannot modify header information – headers already sent” when visiting the login page.

Rel: https://wordpress.org/support/topic/prevent-setting-user-cookies-in-admin-or-on-login-page/#post-14940863