Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9241759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:25:59+00:00 2026-06-18T08:25:59+00:00

I am trying to check if a cookie exists on a server with a

  • 0

I am trying to check if a cookie exists on a server with a specific url.

    $ch=curl_init();
//curl_setopt ($ch, CURLOPT_COOKIE, "mm=38533;" );
curl_setopt($ch,CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_COOKIEFILE,'/tmp/cookies.txt');
curl_setopt($ch,CURLOPT_URL,'http://www.engageya.com');
curl_setopt($ch, CURLOPT_HEADER, 1);
$response=curl_exec($ch);
// get cookie
preg_match('/^Set-Cookie:\s*([^;]*)/mi', $response, $m);

curl_close($ch);

var_dump(parse_url($m[1]));
echo "<br/>".$response;

The problem is when I am logged in onto the target site, and I need to check if I am logged into the site, so I try to retrieve the cookie from the site..But i fail.
I thought to use the curlopt_cookie option..but I thought if there is an easy way to return the cookie from the server and check if it exists .

In short the cookie exists when I surf to the page. But it doesnt exist when the request comes back and i print it

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:26:01+00:00Added an answer on June 18, 2026 at 8:26 am

    Seems that the target host isn’t available. Maybe a typo in url or it is really not available. I added the following option to curl:

    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    

    Now I can see the following error:

    * getaddrinfo(3) failed for www.engagya.com:80
    * Couldn't resolve host 'www.engagya.com'
    

    Update: After fixing the typo in the url, I got the following example working:

    <?php
    
    $ch=curl_init();
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_URL,'http://www.engageya.com/wordpress/api/?action=isloggedin&uid=22472');
    curl_setopt($ch, CURLOPT_HEADER, 1);
    $response=curl_exec($ch);
    curl_close($ch);
    
    // use preg_match to get the cookie as in your question:
    preg_match('/^Set-Cookie:\s*([^;]*);/mi', $response, $m);
    var_dump($m);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to check the output of a cURL. <?php $ch = curl_init(); curl_setopt($ch,
I am trying to check if a cookie exists on a JSP page using
I'm trying to check if a file exists. If I use this: NSData *data
I am trying to check if an email address already exists in a user
I am trying to use a HttpSessionListener to check for a cookie and get
I'm trying to detect the existence of a specific cookie abc. The code that
I am trying to check whether the users have a cookie stored in their
I am trying to check a series of buttons to see if they have
I am trying to check the following and all throw an out of bounds
I'm trying to check a checkbox, i've tried doing the following :- $('#someId').attr('checked','checked'); $('#someId').attr('checked',

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.