Issue with $_COOKIE

Joined
Apr 29, 2021
Messages
4
Reaction score
0
Hello! I'm experiencing a new issue--when I use $_COOKIE["yandex_login"] (the cookie that the API sends to the site which contains the email), it won't work. The code below is supposed to check if the email address contains my domain. It should be reporting "Word Found".

PHP:
<?php
$word = "mail.(my domain)";
$mystring = $_COOKIE["yandex_login"];
if(strpos($mystring, $word) !== false){
    echo "Word Found!";
} else{
    echo "Word Not Found!";
}
?>

The cookie seems to be pushed from domain .yandex.com and the path /

How can I get the value of the cookie if $_COOKIE isn't working? Is there a problem with my code?
 
Joined
Nov 13, 2020
Messages
302
Reaction score
38
This line -> $mystring = $_COOKIE["yandex_login"]; is not correct and you don't set the set the $_COOKIE[] info. Use
Code:
setcookie($mystring, $word);
after line 2.

Code:
<?php

$word = "mail.(my domain)";
$mystring = "yandex_login";
setcookie($mystring, $word);

if(isset($_COOKIE[$mystring]) && ($_COOKIE[$mystring] == $word)){
    echo "Word Found!";
} else{
    echo "Word Not Found!";
}
?>
 
Last edited:
Joined
Apr 29, 2021
Messages
4
Reaction score
0
This line -> $mystring = $_COOKIE["yandex_login"]; is not correct and you don't set the set the $_COOKIE[] info. Use
Code:
setcookie($mystring, $word);
after line 2.

Code:
<?php

$word = "mail.(my domain)";
$mystring = "yandex_login";
setcookie($mystring, $word);

if(isset($_COOKIE[$mystring]) && ($_COOKIE[$mystring] == $word)){
    echo "Word Found!";
} else{
    echo "Word Not Found!";
}
?>
Thanks for the response! Now it's creating a cookie named yandex_login at mail.(my domain). I may have phrased it wrong, I'm sorry. Here's the cookies on the page...

Domain => Name => Value
mail.(my domain) => yandex_login => mail.(my domain) *The code provided made this!
yandex.com => yandex_login => admin@mail.(my domain) *This is what I want to get!

Sorry for the confusion!

EDIT--For clarification, I want the script should check if the cookie yandex_login (the cookie that was sent to my site from yandex.com) contains mail.(my domain).
 
Joined
Nov 13, 2020
Messages
302
Reaction score
38
I gave you this
Code:
if(isset($_COOKIE[$mystring]) && ($_COOKIE[$mystring] == $word)){
    echo "Word Found!";
} else{
    echo "Word Not Found!";
}
Can not you change it to this
Code:
if(isset($_COOKIE["yandex_login"]) && ($_COOKIE[$"yandex_login"] == "mail.(my domain)"){
    echo "Word Found!";
} else{
    echo "Word Not Found!";
}
?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top