InternetGetCookie returning false always,plz help me to read cookie value from VC++
-
InternetGetCookie function is always returning false.I am giving u the code here,can u plz tell me where the mistake is? ------------------------------------------------------------------------------- char szURL[256]="http://www.mirracle.com"; LPWSTR lpszData = NULL; // buffer to hold the cookie data DWORD dwSize=255; // variable to get the buffer size needed LPCWSTR usrauth =NULL; BOOL result=InternetGetCookie(szURL,usrauth,lpszData,&dwSize); DWORD ret; if(result==FALSE) { ret = GetLastError(); if (ret == ERROR_NO_MORE_ITEMS) MessageBox(NULL,_T("no items"),NULL,MB_OK); else if(ret == ERROR_INSUFFICIENT_BUFFER) MessageBox(NULL,_T("insufficient buffer"),NULL,MB_OK); else if(ret == ERROR_INVALID_PARAMETER) MessageBox(NULL,_T("invalid parameters"),NULL,MB_OK); } else { MessageBox(NULL,lpszData,NULL,MB_OK); } The InternetGetCookie function is always returning false here and I am not being able to get the cookie value for this particular site.Plz help me.
-
InternetGetCookie function is always returning false.I am giving u the code here,can u plz tell me where the mistake is? ------------------------------------------------------------------------------- char szURL[256]="http://www.mirracle.com"; LPWSTR lpszData = NULL; // buffer to hold the cookie data DWORD dwSize=255; // variable to get the buffer size needed LPCWSTR usrauth =NULL; BOOL result=InternetGetCookie(szURL,usrauth,lpszData,&dwSize); DWORD ret; if(result==FALSE) { ret = GetLastError(); if (ret == ERROR_NO_MORE_ITEMS) MessageBox(NULL,_T("no items"),NULL,MB_OK); else if(ret == ERROR_INSUFFICIENT_BUFFER) MessageBox(NULL,_T("insufficient buffer"),NULL,MB_OK); else if(ret == ERROR_INVALID_PARAMETER) MessageBox(NULL,_T("invalid parameters"),NULL,MB_OK); } else { MessageBox(NULL,lpszData,NULL,MB_OK); } The InternetGetCookie function is always returning false here and I am not being able to get the cookie value for this particular site.Plz help me.
The way you've specified the output buffer is wrong - YOU have to allocate that buffer - the function won't do it for you. At the moment, you're telling th efunction to put teh cookie data at address zero - always a bad idea. This code seems to work (OK, I've used a different URL - just replace mine with yours):
TCHAR buffer [16384];
DWORD bufferSize = sizeof(buffer)/sizeof(buffer[0]);
BOOL bRes = InternetGetCookie(_T("http://www.codeproject.com"), 0, buffer, &bufferSize); -
The way you've specified the output buffer is wrong - YOU have to allocate that buffer - the function won't do it for you. At the moment, you're telling th efunction to put teh cookie data at address zero - always a bad idea. This code seems to work (OK, I've used a different URL - just replace mine with yours):
TCHAR buffer [16384];
DWORD bufferSize = sizeof(buffer)/sizeof(buffer[0]);
BOOL bRes = InternetGetCookie(_T("http://www.codeproject.com"), 0, buffer, &bufferSize); -
I have tried with the below code: TCHAR buffer [16384]; DWORD bufferSize = sizeof(buffer)/sizeof(buffer[0]); BOOL bRes = InternetGetCookieA(("http://www.mirracle.com"), name, (LPSTR)buffer, &bufferSize); this code is working fine .but I need to get the cookie value,How can I get it?
-
I have tried with the below code: TCHAR buffer [16384]; DWORD bufferSize = sizeof(buffer)/sizeof(buffer[0]); BOOL bRes = InternetGetCookieA(("http://www.mirracle.com"), name, (LPSTR)buffer, &bufferSize); this code is working fine .but I need to get the cookie value,How can I get it?