winHttp.GetAllResponseHeaders exists cookie value but not in the web browser

40 views Asked by At

i try to setcookie with just clicking button in the vb with using winhttp. and i am using php Laravel framework.

this is my vb code

Private Sub Command1_Click()
    Dim winHttp As Object
    Set winHttp = CreateObject("WinHttp.WinHttpRequest.5.1")

    Dim url As String
    url = "http://192.168.0.71:65003/master_login"

    winHttp.Open "GET", url, False
    winHttp.SetRequestHeader "Origin", "http://192.168.0.71"
    winHttp.Send

    Dim responseHeaders As String
    responseHeaders = winHttp.GetAllResponseHeaders

    Debug.Print responseHeaders

    Set winHttp = Nothing

End Sub

web.php Route::get('/master_login',[MainController::class, 'master_login']);

Maincontroller.php function master_login(Request $request){

   $response = response('Your response content');

   $response->header('Access-Control-Allow-Origin', $request->header('Origin'));

        setcookie('test_cookie', 'test_value', [
            'expires' => time() + 3600,
            'path' => '/',
            'domain' => '192.168.0.71',
            'secure' => true,
            'httponly' => true,
            'samesite' => 'Lax',
        ]);

    $responseText = "Cookie set successfully.";


    return response($responseText);

}


the response from vb is like below.

Cache-Control: no-cache, private
Date: Tue, 19 Dec 2023 12:38:04 GMT
Content-Length: 24
Content-Type: text/html; charset=UTF-8
Server: Microsoft-IIS/10.0
Set-Cookie: test_cookie=test_value; expires=Tue, 19-Dec-2023 13:38:04 GMT; Max-Age=3600; path=/; domain=192.168.0.71; secure; HttpOnly; SameSite=Lax
Set-Cookie: XSRF-TOKEN=eyJpdiI6IkNtbDlxeXFzeWx4c1VUdXZRblBcL1NnPT0iLCJ2YWx1ZSI6IkxQRFdVeVYwTnI0NzZuZXVaXC9uUDZudEVLU1ZycFJDUFk0V1hEMkcxVExNYU0yZVNqdTZVbVRSemIwcEppdzc3NVVpek1mMHUrWlZPbTlKUllVb1N3dEw4ajJyajM4QW02NDBwQlwvZ2hmOEkwc3NtNDl5akdvMHFtSVByUml1djAiLCJtYWMiOiJmYjIzZTVkZWVkMTM5MDM5N2JkODY2YWE5YWJlOTdkMTE2MTVjNGI5MjdlNmI2Y2RhMjlmYWNiZjUzZDYxZTU2In0%3D; expires=Tue, 19-Dec-2023 14:38:04 GMT; Max-Age=7200; path=/
Set-Cookie: laravel_session=eyJpdiI6InhpekJoeGJyanIyc0cyT3MxRTJqTXc9PSIsInZhbHVlIjoicGFhWk1Kd1FNOUM4NGU5ZWFkbTYzUzQ1Sk80Zjc3ckQ5RnhHblZJSytLRllqcjBVd0ZMUm8yb3ZleU42cWRaTFNrbWhwSGxnTkN6U0lcL0xEZktZN0FSNnVIV09ZSkd3MHNnWU5zRlNSSmtLSnRRbklMTWtCUGczZk9DQ0kwdzJ3IiwibWFjIjoiN2RhYTIzMWVjMDY0MTUzMmFhNmQxZjVhYTU3NmNjMGMxZmQ1MmRhMDNiY2E5MTgxYzZiNzcwNmMzNTViYmYwMiJ9; expires=Tue, 19-Dec-2023 14:38:04 GMT; Max-Age=7200; path=/; httponly
X-Powered-By: PHP/7.4.33
X-Powered-By: ASP.NET

and this is the image from browser

enter image description here enter image description here

as you can see, i got reponse 'test_cokie' in vb but there are no cookies in the browser. (Application, Network, console.log(document.cookie)) I have tried all the possible solutions but failed. i dont know why i cant search test_cookie in the browser. Can someone please help me solving this issue?

0

There are 0 answers