Welcome to WebmasterWorld Guest from 54.145.167.92

Forum Moderators: open

Message Too Old, No Replies

Block cookies/domains with JS or JQuery?

Is it possible to block cookie domains?

   
9:47 am on Nov 22, 2011 (gmt 0)



I'm wondering if it's possible to block a certain domain from setting a cookie by allowing users to select whether they want that cookie or not.

Example - User visits my site and sees a list of cookies my site uses. He selects the ones he will allow and rejects the others. The script will then only allow loading of the cookies he wants and either remove or block the unwanted ones.

I've tried it with some basic JS I found elsewhere but I'm only a novice coder and would appreciate some direction with this.

Thanks in advance!

Ed
10:51 am on Nov 22, 2011 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Theoretically is possible. You bring up a popup window with the cookies your server will send and ask the user to select which ones he wants. Then is up to your application how it will function with some, all or no cookies.

In reality now something like this will cause all kinds of problems. First the user doesn't necessarily know what each cookie does let alone if he understands about cookies in the first place. Then if he blocks the session cookie for example he may not be able to use certain pages of your site. You will need another tracking mechanism in this case, to identify if it's the same user (for example setting url identifiers).

If it's not for development purposes why would you want to confuse your visitors?
11:18 am on Nov 22, 2011 (gmt 0)

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



I'm wondering if it's possible to block a certain domain from setting a cookie...


Third party cookies? You wouldn't be able to block these without blocking the entire script or setting exceptions in the browser itself I would have thought.

For your own cookies... As enigma1 suggests, this does sound very problematic, unless perhaps you only presented a controlled subset of cookies to your users. You'd probably need some kind of cookie to store which cookies are blocked!? Unless your users are particularly concerned about which cookies are set (although I'm not sure why they should be) then it would perhaps be best to control functionality at a higher level.
4:34 pm on Nov 23, 2011 (gmt 0)



Thanks for your replies. It's for a live site with very specific cookie policies.

I'll keep hacking away at the code and update this thread if I have a breakthrough...
 

Featured Threads

Hot Threads This Week

Hot Threads This Month