Sessions Settings - Possible regression with `Form::hide_session_id()` after PHP 8.4 session changes (v1.1.0.7)

Open to all! Ask other shopowners for help.
azpro
100+
Posts: 184
Joined: Fri Nov 06, 2020 8:25 am
Phoenix Version: v1.1.0.7
Has thanked: 40 times
Been thanked: 49 times

Sessions Settings - Possible regression with `Form::hide_session_id()` after PHP 8.4 session changes (v1.1.0.7)

Post by azpro »

While upgrading my testshop to Phoenix 1.1.0.7, I noticed what appears to be an inconsistency regarding session handling in the admin.

### Configuration

* Phoenix 1.1.0.7
* PHP 8.0.30
* **Force Cookie Use = True**

### Test case

Using a simple GET form in the admin:

Code: Select all

<?= (new Form('status', $Admin->link('orders.php'), 'get'))->hide_session_id() ?>
Submitting this form causes my admin session to be lost and I am redirected to the storefront.

If I remove only hide_session_id()

Code: Select all

<?= (new Form('status', $Admin->link('orders.php'), 'get') ?>
the same form works perfectly.

Additional observation - If I set:

Force Cookie Use = False


the admin form also works, but the storefront starts appending the session ID to URLs again, for example:
shopping_cart.php?sort=1a&ceid=xxxxxxxxxxxxxxxx


So I end up with:

Force Cookie Use = False

* Admin GET forms work.
* Session ID (`ceid`) is appended to storefront URLs.

Force Cookie Use = True

* Storefront URLs are clean (preferred).
* GET forms using `->hide_session_id()` lose the admin session.

Looking at commit https://github.com/CE-PhoenixCart/Phoen ... 77a35aae8b

I noticed that the PHP 8.4 session changes modified both:

* includes/system/segments/application/start_session.php
* includes/system/versioned/1.01.00.07/form.php

It seems that hide_session_id() now always adds the current session ID whenever a session exists, while Href already respects the **Force Cookie Use** setting.

### Question

Is this the expected behaviour?

Should `Form::hide_session_id()` also respect the **Force Cookie Use** configuration when using GET forms, or is there something in my configuration that I have overlooked?

I appreciate any feedback before I start modifying Core code ;) .

Thanks!



Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
burt
Core Team
Posts: 4911
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 296 times
Been thanked: 494 times

Re: Sessions Settings - Possible regression with `Form::hide_session_id()` after PHP 8.4 session changes (v1.1.0.7)

Post by burt »

@BrockleyJohn
I am not here to build for you.
I am here to build with you. Let's help each other.

PiLLaO
100+
Posts: 140
Joined: Thu Nov 05, 2020 9:28 pm
Phoenix Version: v1.1.0.6
Has thanked: 75 times
Been thanked: 19 times

Re: Sessions Settings - Possible regression with `Form::hide_session_id()` after PHP 8.4 session changes (v1.1.0.7)

Post by PiLLaO »

I'm in the same situation, after apply the commit have the same issue.

all urls have ceid, only get off if enable "force use cookies" and I never have this option active before...

And in admin, when using dropdown selection redirect to storefront

PiLLaO
100+
Posts: 140
Joined: Thu Nov 05, 2020 9:28 pm
Phoenix Version: v1.1.0.6
Has thanked: 75 times
Been thanked: 19 times

Re: Sessions Settings - Possible regression with `Form::hide_session_id()` after PHP 8.4 session changes (v1.1.0.7)

Post by PiLLaO »

While I upgrade for newer version and I can check if works... I deleted

* includes/system/versioned/1.01.00.07/form.php

And change the fix:

Code: Select all

$SID = (! empty(session_id()) ? session_name() . '=' . session_id() : '');
with:

Code: Select all

$SID = (session_id() != '' ? SID : '');
That works (for me) like previous code and don't need to active "Force Cookie Use" and admins works again ok

Code: Select all

$SID = (defined('SID') ? SID : '');
Regards

User avatar
burt
Core Team
Posts: 4911
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 296 times
Been thanked: 494 times

Re: Sessions Settings - Possible regression with `Form::hide_session_id()` after PHP 8.4 session changes (v1.1.0.7)

Post by burt »

@BrockleyJohn thoughts?

PiLLaO
100+
Posts: 140
Joined: Thu Nov 05, 2020 9:28 pm
Phoenix Version: v1.1.0.6
Has thanked: 75 times
Been thanked: 19 times

Re: Sessions Settings - Possible regression with `Form::hide_session_id()` after PHP 8.4 session changes (v1.1.0.7)

Post by PiLLaO »

Don't works, I'm still looking for a solution, sorry

PiLLaO
100+
Posts: 140
Joined: Thu Nov 05, 2020 9:28 pm
Phoenix Version: v1.1.0.6
Has thanked: 75 times
Been thanked: 19 times

Re: Sessions Settings - Possible regression with `Form::hide_session_id()` after PHP 8.4 session changes (v1.1.0.7)

Post by PiLLaO »

As I see it, the original code contained the session name and ID only upon the first visit to the website; afterwards, it was always empty, which is why it wasn't being appended to the URLs.

The new code, $SID always contains the session name and ID, and for that reason, it is always appended to the URL.

Piece of code from includes/system/versioned/1.0.8.5/href.php

Code: Select all

// Add the session ID when SID is defined
      if ( $this->include_session
        && Session::is_started()
        && isset($GLOBALS['SID'])
        && !Text::is_empty($GLOBALS['SID']))
      {
        $this->parameters[session_name()] = session_id();
      }

PiLLaO
100+
Posts: 140
Joined: Thu Nov 05, 2020 9:28 pm
Phoenix Version: v1.1.0.6
Has thanked: 75 times
Been thanked: 19 times

Re: Sessions Settings - Possible regression with `Form::hide_session_id()` after PHP 8.4 session changes (v1.1.0.7)

Post by PiLLaO »

This is not a fix it's to hide the error from error_log

Code: Select all

// set SID once, even if empty
  // $SID = (defined('SID') ? SID : '');
  $SID = (defined('SID') ? @constant('SID') : '');

User avatar
BrockleyJohn
Certified Developer
Posts: 162
Joined: Mon Mar 01, 2021 5:37 pm
Phoenix Version: too.ashamed.to.say
Has thanked: 2 times
Been thanked: 41 times

Re: Sessions Settings - Possible regression with `Form::hide_session_id()` after PHP 8.4 session changes (v1.1.0.7)

Post by BrockleyJohn »

I will try harder to reproduce this, and get back to you!

PiLLaO
100+
Posts: 140
Joined: Thu Nov 05, 2020 9:28 pm
Phoenix Version: v1.1.0.6
Has thanked: 75 times
Been thanked: 19 times

Re: Sessions Settings - Possible regression with `Form::hide_session_id()` after PHP 8.4 session changes (v1.1.0.7)

Post by PiLLaO »

I just install to test a new v1.1.0.8 and ceid never hide



Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply