Results 1 to 15 of 15

Thread: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?

  1. #1

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Resolved [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?

    I made a simple browser for my wifes class that can only go to one url but it seems to be remembering the last studient who logged on to the website.

    i wanted to add something on close or load that would wipe out any cookies or cached sites.

    I've been looking around but it looks like everything is geared to wiping out cache files for IE6 or other localy loaded browsers and not just this one instance.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2.0] How can I clear cookies and Cache the webbrowser?

    I assume you used the web browser that 'comes with' Visual Studio, which is in fact a local instance of IE. You can then use Environment.GetFolderPath(Environment.SpecialFolder.Cookies), which you should then scan through for cookies whose names contain the top level domain name of your wife's website. Once you find those, delete it.

    Do this in the application's close event.

    Of course it'll be more useful if you could find some sort of a setting for that browser which cleared cookies upon unloading, but the method I've mentioned above should be good enough for you.

  3. #3
    Lively Member
    Join Date
    Mar 2009
    Posts
    90

    Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?

    can anybody elaborate on this please?

    How do I scan through the cookies? And then how do I delete them?

  4. #4
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?

    You would use the code mendhak provided to get the folder where the cookie files are stored. You'd then have to loop through each file in that folder, for each file (cookie) you'd do some check (such as seeing if it's for the relevent site in the above case), and delete it if appropriate.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  5. #5
    Lively Member
    Join Date
    Mar 2009
    Posts
    90

    Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?

    i'm getting an error, that I cant access the cookie folder.

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?

    Hey,

    Can you post the code that you are using, so that we can verify that you are using it correctly?

    Also, which OS are you using?

    Gary

  7. #7
    Lively Member
    Join Date
    Mar 2009
    Posts
    90

    Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?

    I was using mendhak's code.

    I'm on vs2008express, windows 7

  8. #8
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?

    Does mendhak's code get the correct folder?
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  9. #9
    Lively Member
    Join Date
    Mar 2009
    Posts
    90

    Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?

    I'm using this now:
    Code:
        Function DeleteCookies(ByVal wb As WebBrowser)
            wb.Document.Cookie.Remove(0, (wb.Document.Cookie.Count - 1))
            Delay(1)
            Return False
        End Function
    I think its working.

  10. #10
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?

    Hey,

    Why are you using the Delay? I don't see why that would be needed in this case?

    Gary

  11. #11
    Lively Member
    Join Date
    Mar 2009
    Posts
    90

    Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?

    well idk, I dont want the code to proceed until the cookies are deleted, but maybe thats not the way you do it, just a try.

  12. #12
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?

    Hey,

    Calling Remove is a simple synchronous method, so processing will not continue until that method completes executing, so in this case, the Delay is definitely not needed.

    Gary

  13. #13
    Lively Member
    Join Date
    Mar 2009
    Posts
    90

    Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?

    great, thanks!

  14. #14
    Junior Member
    Join Date
    Aug 2008
    Posts
    17

    Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?

    how would i do this in vb 6?

  15. #15
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?

    Hey,

    If you have a VB6 question, you should post it in the VB 6 Forum.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width