Read cookie["PARENT"]["CHILD"] in PHP

Asked

Viewed 41 times

0

I need to read in PHP an existing cookie, created in classic Asp.

<% Response.Cookies("PAI")("FILHO") %>

I tried to read in PHP this way below and it didn’t work, please help me

<?php
if ( isset($_COOKIE["PAI"]["FILHO"] )) {
    $valor = $_COOKIE["PAI"]["FILHO"];
}
else{
    $valor = 0;
}
echo "cookie: ".$valor;
?>
  • Why didn’t it work? What is the result of var_dump($_COOKIE)?

1 answer

0


I did it this way

if ( isset($_COOKIE["PAI"] )) {    
    $valor = $_COOKIE["PAI"];
    $items = explode("FILHO=", $valor);

    print_r($items);
    RESULTADO DO PRINT_R [
      Array
      (
      [0] => prevlogoff=23/03/2018 13:08:10&dtacesso=23-03-2018 07:08:10&
      [1] => 1
      )
    ]

    echo "01)".$items[1];
}
else{
    echo 0;
}

I know I could have used "&" in the explosion, but this way I got the result I needed. Thank you Guys!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.