Cookies!

This is a discussion on Cookies! within the Windows Programming forums, part of the Platform Specific Boards category; Hi. Do anybody knows how the cookies in Windows Internet Explorer works? I am trying to make a program that ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    7

    Question Cookies!

    Hi.

    Do anybody knows how the cookies in Windows Internet Explorer works?

    I am trying to make a program that will help me log in / log out of my frequent websites at a click of the button.

    I have tried cutting the "website[1].txt" from the "C:\Documents and Settings\UserName\Cookie" and pasting it back but it did not work. I am unable to find what other changes Windows Internet Explorer make. I tried searching for "webuserrname" in the registry but did not find any.

    Thanks in advance.

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,265
    Cookies are given to the client from the webserver. You cant just generate your own cookie, you need to receive one from the webserver with a request. The reason for this is that many (not all) servers invalidate the cookies after a certain amount of time. This is done for security reasons, and therefore you need to get a new cookie from the server.

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    You can use the InternetSetCookie() function to set a cookie value that will be picked up by Internet Explorer (but not other browsers). However, as mentioned by bithub, you typically need to logon to get the correct cookie value anyway.

    This code seems to work to logon to cboard. You can get the correct value for bbuserid and bbpassword from inside the IE cookie file or from Firefox.

    Code:
    #include <windows.h>
    #include <wininet.h>
    #pragma comment(lib, "wininet.lib")
    
    int main (void) 
    {
    
    	InternetSetCookie(TEXT("http://cboard.cprogramming.com"), TEXT("bbuserid"), 
                              TEXT("1001; expires = Sat, 01-Jan-2005 00:00:00 GMT"));
    
    	InternetSetCookie(TEXT("http://cboard.cprogramming.com"), TEXT("bbpassword"), 
                              TEXT("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; expires = Sat, 01-Jan-2005 00:00:00 GMT"));
    
    	return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 11-16-2008, 10:29 PM
  2. First party tracking cookies Meow!
    By kryptkat in forum Tech Board
    Replies: 13
    Last Post: 08-12-2006, 07:29 PM
  3. Using wininet with cookies
    By bithub in forum Windows Programming
    Replies: 4
    Last Post: 06-01-2006, 11:10 PM
  4. Replies: 13
    Last Post: 08-18-2003, 08:42 AM
  5. Math Test Problem Disagreement
    By orbitz in forum A Brief History of Cprogramming.com
    Replies: 29
    Last Post: 02-28-2003, 04:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21