Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Array values in a Cookie throws an Exception since Symfony v3.3 #19443

Copy link
Copy link
Closed
@thomxc

Description

@thomxc
Issue body actions
  • Laravel Version: 5.4.24
  • PHP Version: 7.0
  • Database Driver & Version: MySQL 5.7

Description:

I ran into a bug regarding cookies that's directly related to a recent update of the symfony/http-foundation package: 3.2.9 -> 3.3.0. I think I found the pull request that's responsible for this as well.
The problem occurs when putting array values in a Cookie and attaching it to the response headers.

Steps To Reproduce:

code:

<?php
namespace App\Controllers;

class CookieController
{
    public function createCookie()
    {
        $array = array(0 => 1);
        $cookie = cookie('array', $array, 0);
        return response(['message'], 200)->withCookie($cookie);
    }
}
  1. make sure you update your packages with composer and "symfony/http-foundation": 3.3.* is installed;
  2. test the above code using a route to the above controller and action method;
  3. an exception occurs saying:
 [Symfony\Component\Debug\Exception\FatalErrorException]                      
  Method Symfony\Component\HttpFoundation\Cookie::__toString() must not throw  
   an exception, caught ErrorException: Array to string conversion 

The code above is a simple as I can reproduce the code I have in my production application. I've tested the same code using a fixed dependency to "symfony/http-foundation": 3.2.* and the code runs without a problem.
I don't have enough deep knowledge of symfony to suggest a fix. But maybe another contributor understand what's going on here. I'm using this code since Laravel 4.2 and always worked.

Let me know if I need to elaborate some more!

Thomas,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.