How to continue a CakePHP 3 session in a regular PHP script?

后端 未结 1 1194
情深已故
情深已故 2021-01-24 20:19

My situation is the following. I have a cakephp project and a seperated plain php script running on the same server. When I use my client browser to connect to the cakephp proje

相关标签:
1条回答
  • 2021-01-24 20:36

    CakePHPs PHP session defaults (like all built-in defaults) do change the name of the cookie / the name of the session (session.name INI setting) to CAKEPHP:

    https://github.com/cakephp/cakephp/blob/3.5.3/src/Network/Session.php#L133-L138

    So you either have to change that to match the defaults used by your vanilla PHP app (which is most probably PHPSESSID, ie the PHP default):

    'Session' => [
        'defaults' => 'php',
        'cookie' => session_name(), // would use the PHP default
    ],
    // ...
    

    or change the latter app to use the name configured for your CakePHP application:

    session_name('CAKEPHP');
    session_start();
    // ...
    

    Also make sure that the session.cookie_path and session.cookie_domain configuration covers both of your applications locations.

    See also

    • Cookbook > Sessions > Session Configuration
    • Cookbook > Sessions > Setting ini directives
    0 讨论(0)
提交回复
热议问题