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 6924299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:38:45+00:00 2026-05-27T10:38:45+00:00

I am having a really hard time with some API calls to the Wininet

  • 0

I am having a really hard time with some API calls to the Wininet dll. I am trying to read cookies client side set by IE 9. Here’s the code.

     #include "stdafx.h"
     #include <Windows.h>
    #include <WinInet.h>
    #include <iostream>
    int _tmain(int argc, _TCHAR* argv[])
    {

LPTSTR lpData = NULL;
DWORD dwSz = 500; 
std::cout << "Hello Chris" << std::endl;
lpData = new TCHAR[dwSz];

std::wcout << "Arg 0: " << argv[1] << std::endl;


bool val = InternetGetCookieEx(argv[1], argv[2], lpData, &dwSz,  INTERNET_COOKIE_THIRD_PARTY | INTERNET_FLAG_RESTRICTED_ZONE, NULL);

    if (!val)
    {

        if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
        {
            std::cout << "Insufficent Buffer size" << std::endl;
            lpData = new TCHAR[dwSz];
            val = InternetGetCookieEx(argv[1], argv[2], lpData, &dwSz, INTERNET_COOKIE_THIRD_PARTY | INTERNET_FLAG_RESTRICTED_ZONE, NULL);
            if (val)
            {
                std::cout << "Cookie Data: " << lpData << std::endl;
            }
            else
            {
                std::cout << "ERROR Code: " << GetLastError() << std::endl;
            }
        }
        else 
        {
            int err = GetLastError();
            std::cout << "ERROR Code: " << err << std::endl;
        }
    }
    else
    {
                        std::cout << "Cookie Data: " << lpData << std::endl;
    }
//}


return 0;

}

The problem that I am having is that when I call InternetGetCookeEx I always return false and get an error code of 259, which means no more data available. When you consult the API essentially what that means is that it couldn’t find my cookie.

Because I am using IE 9 the names for files that the cookie is being stored in are obviously mangled , which is why I am trying to read my cookie data that way.

I have removed the company name to protect the company. Essentially what I am trying to do is. Find the lUsrCtxPersist cookie value. Therefore I am calling the code as such CookieReader.ext http://[CompanyDomain].com lUsrCtxPersist.

However I always get a false and an error code of 259. Any light you might be able to shed on this would be greatly appreciated.

  • 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-05-27T10:38:46+00:00Added an answer on May 27, 2026 at 10:38 am

    Assuming the cookie name is correct, then try removing the INTERNET_COOKIE_THIRD_PARTY and/or INTERNET_FLAG_RESTRICTED_ZONE flags and see what happens. Or try calling InternetGetCookie() instead, which has no such flags available.

    On a separate note, when InternetGetCookieEx() returns ERROR_INSUFFICIENT_BUFFER, you are leaking memory. You need to delete[] your existing buffer before then calling new[] to allocate a new buffer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to iPhone programming and am having a really hard time trying
I'm having a really hard time when trying to cancel requests in an NSOperationQueue.
I am having a really hard time attempting to debug LINQ to SQL and
I am having a really hard time reconciling IoC, interfaces, and events. Let's see
I'm having a really hard time understanding delegates and object inheritance (if I may
I just start playing with GWT I'm having a really hard time to make
I'm having a hard time getting some sql in python to correctly go through
I'm having a hard time wrapping my head around this and need some help
I'm having hard time trying to use teasers post in my wordpress theme (based
I just setup a wordpress blog and I am having a really hard time

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.