Skip to content

Bug: session()->push() Strange behavior #2786

Description

@MisterAnmar

Trying to build a cart using session and a came across a strange behavior (actually few).

  1. push()
    in construct()
if (is_null(session('cart'))) {
session()->set('cart', [ ]);
}

then on a different method on the same controller i have the following code

$item = ['test' => 20];
session()->push('cart', $item);

it seems that this method does not work if the session is set but does not contain a value example

if (is_null(session('cart'))) {
session()->set('cart', ['id', 50]);
}

then it works fine.

Also
session()->destroy() does not destroy the session only partially (Some variables stay)

i have to use native PHP $_SESSION = arrary(); to reset all session into empty array.

CI4.0.2 using composer appstarter --no-dev (installed today)
PHP 7.3.5
Apache 2.4.39
Win10

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions