For the PHP project, the response header returns setCookie, but why didn't the server create a corresponding seesion?

I use GUZZLE to create a httpclient simulation to request my own phpweb project, and confirm that the web project has session_start (). After the simulated login request is successful, there is Set-Cookie in the response-header. When I use the PHPSESSID in set-cookie to request the next page, seesion is not available. Go to the server to check that there is no corresponding session in session_save_path.

I use a browser to access and log in to get cookie, and then write it into the code to pass, indicating that the request code is fine. And the cookie obtained by the browser has a corresponding session in the session_save_path of the server.

related codes

$client = new Client([
            "base_uri" => "http://my.domain.com",

        ]);
        $response = $client->request("POST","/?action=sys&opt=login",[
            "action"=>"login",
            "uName"=>"myUName",
            "uPass"=>"myPwd",
        ]);
        print_r($response->getHeader("Set-Cookie"));//Array([0] => PHPSESSID=22fosfolsvoqardv5atdg0cnr2; expires=Sat, 19-Jan-2019 03:45:38 GMT; path=/; domain=my.domain.com)
        $cookie = substr((explode(";",($response->getHeader("Set-Cookie"))[0]))[0],10);


        $jar = CookieJar::fromArray(["PHPSESSID"=>$cookie],"my.domain.com");
        $response = $client->request("GET", "/?action=game&opt=gameindex&type=add",[
            "cookies"=>$jar
        ]);

you can confirm that no response-header returns the corresponding session in the cookie in the server"s session save path, and the session name has not been set. The cookie obtained through the browser is available. Please point out your mistakes. Thank you.

Php
May.09,2022

or ask and answer yourself, it seems that there is very little phper in sf.
through the remote debugging of xdebug, I found that there is a Session ['uName'] judgment in my web code that destory_session () deletes the server's session file when it is empty.
I have a spelling error here

$response = $client->request('POST','/?action=sys&opt=login',[
            'action'=>'login',
            'uName'=>'myUName',
            'uPass'=>'myPwd',
        ]);

this should be changed to

$response = $client->request('POST','/?action=sys&opt=login',[
            'form_params' => [
                'action'=>'login',
                'uName'=>'myUName',
                'uPass'=>'myPwd',
                ]
        ]);
The parameters of

post will be sent correctly. Well done!

Menu