|
-
Nov 30th, 2005, 02:09 PM
#1
Thread Starter
Frenzied Member
Store Cookies!
I am using the WebBrowser control to make a browser. As far as IE is concerned, all cookies are stored in a temporary folder (cache).
I want my application to be totally independent of IE. So, like IE, I want to store cookies in a temporary folder (not the folder where IE stores). How would I do that? First of all how do I find out whether the web site a user has visited or is currently viewing creates cookies or not? If yes. then how do I store those cookies in a temporary folder? Also when a user visits a URL which he had previously visited & that had created cookies, how do I make the browser read those cookies?
Thanks,
Arpan
-
Nov 30th, 2005, 02:26 PM
#2
Re: Store Cookies!
 Originally Posted by arpan_de
I am using the WebBrowser control to make a browser.
I want my application to be totally independent of IE.
I hope some one else besides myself enjoys the irony and contradiction of those two statements.
You do (I hope) realize that the WebBrowser control is in fact the VERY same control that is a part of IE?
-tg
-
Nov 30th, 2005, 03:16 PM
#3
Hyperactive Member
Re: Store Cookies!
Hello
i can show you how to do it in JavaScript , see if you can change the code to
work with your Web Browser control.
Code:
<SCRIPT type="text/javascript" language="javascript">
/**
* Sets a Cookie with the given name and value.
*
* name Name of the cookie
* value Value of the cookie
* [expires] Expiration date of the cookie (default: end of current session)
* [path] Path where the cookie is valid (default: path of calling document)
* [domain] Domain where the cookie is valid
* (default: domain of calling document)
* [secure] Boolean value indicating if the cookie transmission requires a
* secure transmission
*/
function setCookie(name, value, expires, path, domain, secure)
{
document.cookie= name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}
/**
* Gets the value of the specified cookie.
*
* name Name of the desired cookie.
*
* Returns a string containing value of specified cookie,
* or null if cookie does not exist.
*/
function getCookie(name)
{
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1)
{
begin = dc.indexOf(prefix);
if (begin != 0) return null;
}
else
{
begin += 2;
}
var end = document.cookie.indexOf(";", begin);
if (end == -1)
{
end = dc.length;
}
return unescape(dc.substring(begin + prefix.length, end));
}
/**
* Deletes the specified cookie.
*
* name name of the cookie
* [path] path of the cookie (must be same as path used to create cookie)
* [domain] domain of the cookie (must be same as domain used to create cookie)
*/
function deleteCookie(name, path, domain)
{
if (getCookie(name))
{
document.cookie = name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}
As you can see in setCookie function you can write the path for the cookie.
Best Regards,
ERAN
Eran Fox
ASSEMBLER,C,C++,VB6,SQL...
-
Nov 30th, 2005, 05:02 PM
#4
Re: Store Cookies!
That path doesn't control WHERE the cookie is physicaly stored on the user's PC. It only controls what path the cookie is available to.
-tg
-
Nov 30th, 2005, 11:59 PM
#5
Thread Starter
Frenzied Member
Re: Store Cookies!
I hope some one else besides myself enjoys the irony and contradiction of those two statements.
You do (I hope) realize that the WebBrowser control is in fact the VERY same control that is a part of IE?
I am very well aware of the fact that the WebBrowser control is a part of IE but I guess you have misunderstood what I meant by I want my application to be completely independent of IE. An example of what I meant is when I click the Clear History button in my application, IE history shouldn't get cleared; it should remain as it is & only the history a user has accumulated using my application should be deleted. Another example would be when the home page in my application is changed by a user, the home page of IE should remain as it is & only the home page of my application should change & vice-versa. Yet another example would be if a user adds a URL in his Favorites folder using my application, that URL should be listed in the Favorites menu of my application only & not IE. The same holds true when a Favorite is deleted & vice-versa. Need any more examples? This is what I meant by saying I want my application to be completely independent of IE.
i can show you how to do it in JavaScript , see if you can change the code to work with your Web Browser control.
I will surely give it a try, Eranfox. In fact, after going through your suggestion, I will try it using ASP (since ASP uses VBScript & VBScript is somewhat similar to VB).
Arpan
-
Dec 1st, 2005, 01:09 AM
#6
Frenzied Member
Re: Store Cookies!
AFAIK javascripts are part of the website it is contained in and they are not allowed to physically store cookies anywhere else except the predefined location. please tell me if i am wrong.
what u can do is to chage the windows properties, manually, like this.(NOTE win xp sp2: my comp)
-right click on my computer and goto properties.
-select the advanced tab.
-click on the "Environment Variables" button.
-there are 2 lists, 1 for user variables and one for system variables. i recommend u use system restore first in case u screw up.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|