Four Spaces Before <?php — DeepSeek Tips & Insights
    Neura MarketNeura Market/DeepSeek
    ChatGPTChatGPTClaudeClaudeGeminiGeminiCursorCursorGrokGrokPerplexityPerplexityDeepSeekDeepSeek
    CoPilotCoPilotStable DiffusionStable DiffusionMidjourneyMidjourney
    View All Directories
    OverviewRulesPromptsMCPsAgentsGamesBlogVideosGuidesCoursesCommunityTrending
    DeepSeekBlogFour Spaces Before <?php
    Back to Blog
    Four Spaces Before <?php
    php

    Four Spaces Before <?php

    Bruno Pinto February 10, 2026
    0 views

    I was working on a Livewire component when every interaction started throwing 419 errors. CSRF token...

    I was working on a Livewire component when every interaction started throwing 419 errors. CSRF token mismatch, on every click. The kind of thing that makes you question your setup immediately.

    At first I assumed it was a Livewire issue. But then I noticed something stranger — every page refresh generated a new session ID. Sessions worked fine with php artisan serve, but the moment I switched to Herd, no cookies stuck. Each request was a clean slate.

    The 419 errors were just a symptom. Laravel couldn't maintain sessions because the browser never received a cookie.

    Chasing the usual suspects

    I started with the .env file:

    SESSION_DRIVER=redis
    SESSION_LIFETIME=120
    SESSION_DOMAIN=null
    SESSION_SECURE_COOKIE=false
    

    Redis was running, PHP could connect to it. I created a test route to confirm sessions worked at the PHP level — they did. Data was stored, but the browser never got the Set-Cookie header.

    I checked DevTools. No laravel_session cookie. No Set-Cookie header at all.

    I went through the usual list: cookie domain, HTTPS settings, session path, Redis connection. All fine. Switched to the file driver. Same result. Tried setting a cookie manually:

    Route::get('/cookie-test', function () {
        return response('Test')
            ->cookie('test_cookie', 'test_value', 60);
    });
    

    Still no Set-Cookie header. At this point it clearly wasn't a Laravel config problem. Something was preventing PHP from sending cookies entirely.

    The actual problem

    The breakthrough came from a raw header() call:

    Route::get('/header-test', function () {
        header('X-Custom-Test: working');
        // ...
    });
    

    PHP responded with: "Cannot modify header information — headers already sent", and pointed to routes/web.php:1.

    Line 1 should just be <?php. I opened the file and there it was — the tag was indented. Four spaces sitting right there, plain as day. I just hadn't noticed.

    Why it only showed up in Herd

    The bug existed all along. php artisan serve has output buffering enabled by default, so those spaces never reached the browser before the headers. The problem was silently masked.

    Herd uses nginx + PHP-FPM with output_buffering = 0. Output goes out immediately. Those four spaces hit the browser before Laravel could send any headers — which meant no cookies, which meant no sessions.

    The fix

    Delete four spaces. That's it.

    I made sure routes/web.php started with <?php on the very first character of the very first line. Saved. Everything worked.

    Livewire relies on the session to verify CSRF tokens on every request. Without a Set-Cookie header, the browser never stores a session — and without a session, every Livewire interaction fails with a 419.

    Four spaces before <?php were enough to start the response body, and once the body starts, PHP can't send headers anymore.

    Tags

    phplaraveldebugging

    Comments

    More Blog

    View all
    Five Gemma-4 models, one accelerator: what porting E2B 31B to AWS Inferentia2 taught megemma

    Five Gemma-4 models, one accelerator: what porting E2B 31B to AWS Inferentia2 taught me

    I ported the whole Gemma-4 family — E2B, E4B, 12B, 31B, and the 26B-A4B MoE — to run on...

    X
    xbill
    Hey DEV, I'm Tobore. Let's actually connect.community

    Hey DEV, I'm Tobore. Let's actually connect.

    Hey DEV, I'm Tobore. Let's actually connect. I've been on here for a while now, mostly writing and...

    L
    Laurina Ayarah
    I burned through thousands of AI tokens. Then a friend did it for freeai

    I burned through thousands of AI tokens. Then a friend did it for free

    (yep, kinda clickbait, just for the funsies 😊) At the beginning of the year, I relaunched my...

    P
    Paulo Henrique
    Claude might be saturating your machineai

    Claude might be saturating your machine

    My laptop was sitting idle with the fan at full tilt. Nothing was running that I knew of. The culprit...

    S
    Sidhant Panda
    Automated GitHub Code Reviews Using Google Geminigithubactions

    Automated GitHub Code Reviews Using Google Gemini

    I Built a Thing! TL;DR — Google Gemini-based Pull Request reviews and Issue Triaging for...

    D
    Darren "Dazbo" Lester
    What is an "agentic harness," actually?ai

    What is an "agentic harness," actually?

    I've been hearing the word "harness" thrown around a lot lately. I assumed it just meant "the IDE" or...

    T
    Tilde A. Thurium

    Stay up to date

    Get the latest DeepSeek prompts, rules, and resources delivered to your inbox weekly.

    Neura Market LogoNeura Market

    Discover the best AI prompts, plugins, and resources for DeepSeek and more.

    Content Types

    • Rules
    • Prompts
    • MCPs
    • Agents
    • Guides

    Platforms

    • ChatGPT Directory
    • Claude Directory
    • Gemini Directory
    • Cursor Directory
    • Grok Directory
    • Perplexity Directory
    • DeepSeek Directory
    • CoPilot Directory
    • Stable Diffusion Directory
    • Midjourney Directory
    • All Directories

    Resources

    • Blog
    • Documentation
    • Help Center
    • Marketplace

    Legal

    • Privacy Policy
    • Terms of Service

    © 2026 Neura Market. All rights reserved.

    |

    Not affiliated with any AI platform vendors.

    Neura Market

    Custom AI Systems & Services

    Our team of experienced AI builders will help build custom AI systems, workflows, and solutions for your business.

    Request custom work

    Ready-made automations for this

    Workflows from the Neura Market marketplace related to this DeepSeek resource

    • AI-Driven Document Interaction Using Nextcloud and OpenAIn8n · $14.99 · Related topic
    • Conversational AI for Snowflake Database Interactionn8n · $14.99 · Related topic
    • AI-Enhanced WhatsApp Chatbot for Multimodal Interactionn8n · $19.99 · Related topic
    • Automate Professional Engagement on X with AI-Powered Tweet Interactionn8n · $14.99 · Related topic
    Browse all workflows