swooletw / laravel-swoole

High performance HTTP server based on Swoole. Speed up your Laravel or Lumen applications.
MIT License
4.04k stars 390 forks source link

laravel.ERROR: Cannot modify header information - headers already sent #426

Closed gliese436-b closed 4 years ago

gliese436-b commented 4 years ago

Make sure you read Issues Guideline and answer these questions before submitting your issue. Thanks! (Any non-English issues will be closed immediately.)

  1. Please provide your PHP and Swoole version. (php -v and php --ri swoole)

PHP:7.3.2 Swoole:4.4.8

  1. Please provide your Laravel/Lumen version.

Laravel:6.2

  1. Which release version of this package are you using?

    "swooletw/laravel-swoole": "^2.6"

  2. What did you do? If possible, provide a recipe for reproducing the error.

    setcookie('token',null,time() - 1,'/','.test.cn');

OR

header("Location:https://xxx.comt");

  1. What did you expect to see?

  2. What did you see instead?

laravel.ERROR: Cannot modify header information - headers already sent

mxp100 commented 4 years ago

use via response, this is bug of laravel (not laravel-swoole) Example: response()->cookie() or response()->header()

Arkanius commented 4 years ago

As @mxp100 said, after start using swoole you need to use Laravel's response, request, etc.

Check: https://github.com/swooletw/laravel-swoole/wiki/Z1.-Notices