View Full Version : Can I save cookies in different folder other than the default one?

04-21-2005, 02:20 PM
Hi All,

My application saves cookies by default in cookies folder (IE). BUt the problem is that few users have restrictions on their computers and automatically a scheduled task clears their cookies on daily basis. This is hectic for them to reset the cookies again.

To resolve this issue and unburden those users, I have a set of questions?
1) Can i save cookies in different folder and then read it from there? Logic behind is that since the scheduled task that deletes the cookies, cleans up the cookies folder, but if the cookie file related to my application is stored in different location it won't delete it and users can still see their customizations.

2) If this can be done, then how?

3) Other wise, is there any other alternative to cookies in such scenarios?

4) can i have permanent cookies that cannot be deleted at all unless user wants it to?

Thanks in advance,
Programmer in distress

04-21-2005, 02:59 PM

In answer to your questions:

1) The cookie object does not allow saving to any other folder than the cookies folder.

2) As answer to 1) is no this is null

3) Your options are either to
- save a "user options" file on their machine using the File System Object (an activeX object with all the security pop-up warnings etc that comes with using that)

- Use an external data source (like MySQL, SQL Server, MS Access) running over the internet (or intranet) and potentially using a login script for the users to retrieve their preferences - or grabbing their details by their windows logon/ip address/etc if possible.

- Introduce an application/script that copies the cookies out of the cookies folder before your scheduled cookie deletion task is launched and then moves them back after it has finished. Conversely you could might be able to get your scheduled task to leave your required cookies alone and delete the others?

4) You can set the expiry date of the cookie way into the future something like:

var today = new Date();
var expiry = new Date(today.getTime()+999*24*60*60*1000);

Which would set the cookie to expire in 999 days. This would just mean the cookie doesn't expire for ages, but if there is a mass cookie deletion, it will disappear.

Sorry for the bad news.

Mostly it's a security risk to save cookies outside of the cookies folder, or using javascript to save a file to the user's machine elsewhere. If I were you, i would be inclined to look towards saving the user options into a database (MySQL, SQL Server, MS Access, etc) and reading them out of there, resetting the cookies en masse the first time the user visits the page and says "i'm here".

Hope this helps


05-26-2005, 06:25 AM
Hi Martin,

Thanks for your input on my query "can i save cookies in different folder?" i would like u to elaborate more on the alternatives-

1) File System Object - Can you suggest me a site that will be useful or an example.

2) Database - demo

3) Application script - example
i would really be greatful.

programmer in distress.