Using the set cookie header

I wrote the following code to test for cookie support.  My browser accepts cookies but this code does not detect the cookie it sets.  What is the correct method for checking if a browser accepts cookies?

int main(int argc, char *argv[])
     char *pszCookie;
     char *pszQueryString;
     char *szLocation = "http://yoursite/cgi-bin/cookie.exe?TEST";
     char reply[256];

     pszQueryString = getenv("QUERY_STRING");


          if(strncmp(pszQueryString,"TEST",4) == 0)
                 pszCookie = getenv("HTTP_COOKIE");

                      if(strcmp(pszCookie,"Cookie=test") == 0)
                            sprintf(reply,"%s","<HTML><TITLE>Good Cookie!</TITLE><BODY>Your browser supports "\
                                            "the Netscape HTTP Cookie Specification as set by including a Set-Cookie "\
                                            "HTTP Header!</BODY></HTML>");
                      sprintf(reply,"%s","<HTML><TITLE>Bad Cookie</TITLE><BODY>Sorry, Your browser "\
                                           "doesn't appear to support the cookie protocol. If you believe you have "\
                                           "gotten this message in error... Don't eat cookies</BODY></HTML>");

                 printf("Content-Type: text/html\n\n");


          printf("HTTP/1.0 302 Moved Temporarily\r\n");
          printf("Location: %s\n\n",szLocation);
          printf("Set-Cookie: Cookie=Test\n\n");

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
marcus_careyAuthor Commented:
This,, example works but I guess I worded the question wrong.  I already know that IE supports cookies.  The idea is to test rather cookie support is enabled by setting a cookie value then redirecting to another page to see if the browser saved it.  

'declare our variables
Dim blnCookies , objBrowser
'create an instance of browsertype object
Set objBrowser = Server.CreateObject("MSWC.BrowserType")
'set blnCookies to either true or false
blnCookies = objBrowser.cookies
'if true the display this message
If blnCookies = True Then
Response.Write "Cookies are supported in this browser"
'if false display this message
Response.Write "Cookies are not supported in this browser"
End If
'destroy the object
Set objBrowser = nothing
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.