Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    New Coder
    Join Date
    Jun 2012
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question Help with Cookies

    Hi there I need some help about setting up a a message box that tells viewers that my site uses cookies, This is due to the new EU law about having to ask their permission to save cookies. I have never manually set up cookies before and I'm having difficulty finding exactly what I want/need.

    Basically when the viewer first looks at the site there is a box at the top which explains that the site uses cookies, they can either view what the cookies do, accept or not accept. example http://www.bbc.co.uk/

    I have the box already in place what I need now is a script that if the viewer clicks Yes and accepts then the box will hide and stay hidden until the user deletes the cookies from their browser.

    I hope this makes sense.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    What do the cookies do?

    And if they don't accept cookies, how do you know they choose to
    not use cookies when they leave the site and return? You can't use
    a cookie to know that they choose not to accept them.

    What about PHP SESSION? Is that acceptable to use?

    ... and what is an EU law?

  • #3
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,637
    Thanks
    6
    Thanked 1,004 Times in 977 Posts
    Quote Originally Posted by mlseim View Post
    ... and what is an EU law?
    EU = European Union. But you are correct, the EU can’t pass laws, it can only enact directives that the associated countries have to make into laws.

  • #4
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    Quote Originally Posted by mlseim View Post
    ...

    And if they don't accept cookies, how do you know they choose to
    not use cookies when they leave the site and return? You can't use
    a cookie to know that they choose not to accept them.

    ...
    lmao , brilliant , that pretty much sums up the total pointlessness of the `law` and gives you an idea about the level of expertise advising the bureaucracy
    ... and what is an EU law?
    part of the reason that Europe is getting into the mess that its in, pointless expensive bureaucracy
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #5
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    And as far as I know ... there is nothing dangerous with cookies.
    Cookies add effective, positive features to a website/browser experience.
    The same thing for AJAX, JQuery and SESSIONS.

    I wonder what they'll say when the internet begins controlling physical things:

    http://www.electricimp.com/
    Coming sometime this month ... an interesting, cheap method to connect physical
    things with the internet and websites. This will use a "cloud". But it's basically
    I/O electronics interfaced to the internet for less than $50.

    http://www.openpicus.com/
    The FlyPort has existed for some time now. Not quite as easy to set-up as the
    new Imp will be, but people are using the internet (smart phones, iPad, iPhone, etc)
    to control things all over the world. This is currently about $85 for a development kit.

    Can you imagine the implications of this when used maliciously? Like an IED?

    We (the world) will be walking around with handheld devices for a physically
    controlled environment. Let's see what the EU law says about that.

    We're talking about making REAL cookies, not just browser cookies.


    .

  • #6
    New Coder
    Join Date
    Jun 2012
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Cheers for the replies guys.

    Yeah the EU (European Union) have said that we have to ask the viewers permission to store cookies, they have not said exactly what we have to do but some people have an opt out of cookies but explain that it may effect their visit to the site OR warn them that you are using cookies and do they accept, you also have to include what your cookies do (having this on a terms & conditions or info page is not acceptable.

    Back to my original question though, Im helping out with a friends site and it needs to have this warning on there. I have created a css popup that appears when the page is opened with the relative info but I need it that if the viewer agrees by clicking YES (text link) that it will remember this and not show on any other page or on their next visit unless they delete their cookies.

    The link to the sit is http://www.hudsonmotorcompany.co.uk You will see the box at the top, if you click YES it will disappear but if you refresh it will reappear (don't want this) and if you click NO it'll bring another warning up and if they press CONTINUE it will mean they have agreed and do the same as YES.

    PS - I have only attached to index page at the moment until I get this problem sorted so it at least has the warning there.
    Last edited by Pezmo82; 06-09-2012 at 06:54 PM.

  • #7
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    You'll have to use PHP SESSION to remember it for the existing browser session.
    But can you use PHP SESSION?

    SESSION is stored on the server, but a temporary ID is stored on the client's PC.

    So essentially, SESSION does the same thing as a cookie except it is removed when the
    browser closes or the user "logs-off" (closes the session). A regular cookie can also
    have that same feature ... dying when the browser closes.

    $_COOKIE and $_SESSION both store something on the user's PC.

    So my answer to you is no ... you cannot do what you wish to do.

    ... and what about pop-ups? what if those are suppressed?

  • #8
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,637
    Thanks
    6
    Thanked 1,004 Times in 977 Posts
    Quote Originally Posted by mlseim View Post
    And as far as I know ... there is nothing dangerous with cookies.
    It depends what you define as “dangerous”. Cookies can, for example, be used to track your interaction on websites and create a detailed user profile about you that could be used to your disadvantage. Let’s use Facebook as example: Wherever there is a “Like” button (or any FB widget) on a site, Facebook stores a cookie in your browser and adds new info to that cookie to store which FB users’ sites you have visited (among other things, most likely). With enough data a clear profile of your personality can be created, even if you’re not even registered at Facebook. And if you decide to register at Facebook some time later, the info from that cookie is used to suggest you exactly those people as friends whose websites you have visited, among other things.

    Now, this might sound harmless to some people but there are increasing efforts to use just that data for police or even tax investigation (no kidding, there has just recently been a highly criticized announcement from a German credit agency that was researching the possibilities of using information from social networks to help in determining the personal credit rating). They know almost everything about you exactly with the help of cookies.

    Quote Originally Posted by mlseim View Post
    Cookies add effective, positive features to a website/browser experience.
    The same thing for AJAX, JQuery and SESSIONS.
    Of course, cookies can be useful. So can smartphones, but look for how much useless crap they are used nowadays. As soon as something useful for mankind is invented someone comes by and misuses it for irrelevant crap, just because it’s possible.

    The point of that directive is that websites are generally forbidden to store cookies in the user’s browser that are unrelated to the actions/intentions the user takes/has, unless the user actively opts in. Here is the relevant paragraph about that from an interesting read about that law as passed in the UK:
    The only cookies that do not need users' consent are those that are necessary to fulfill the user's request. That will cover, for example, the use of cookies to remember the contents of a user's shopping cart as the user moves through several pages on a website. Other cookies, including those used to count visitors to a site and those used to serve advertising, will require consent.
    That means, any tracking cookies or cookies that have nothing to do with the direct enhancement of the user experience, are forbidden and need consent.
    Last edited by VIPStephan; 06-10-2012 at 12:20 AM.

  • #9
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    That's going to be a tough one to enforce.
    It's a judgement call on what is considered necessary.

  • #10
    New Coder
    Join Date
    Jun 2012
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts
    The site in question can use php, it was built using alot of php. I have only started to use php through helping this guy with his site so i dont understand the ins and outs of it.
    You can still use cookies on your site you just have to ask permission first off, what I need is a code i can link to YES and CONTINUE that will save something so that if the viewer clicks yes it will remember this on their next visit and not show the same message again.
    I know this can be done as many sites already have it i'm just not sure how to implement it to the box I have created.

    http://www.hudsonmotorcompany.co.uk (site in question)
    http://www.bbc.co.uk (site that has this function)

    As for the popup its html / css its just a div that shows when needed and hiden when not needed, I just
    cant work out the hiden part as I've never used Cookies.

    If a $_SESSION only lasts whilst the viewer browses the site, the next time they go on they're gonna see the message again, so I need a $_COOKIE then as i don't want it annoying the viewer everytime they visit. I know that a cookie you can change its expiration time so it can be set for say 90 days.
    Last edited by Pezmo82; 06-10-2012 at 02:08 AM.

  • #11
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    OK ... as the rules stated by Stephan ...

    You can and will use one cookie to remember if they are supposed to allow cookies.
    That one cookie is valid and legal because it's a necessary part of the script operation.

    You now need to determine what will happen if they DON'T want to use cookies.
    By that I mean, as the website is displayed and operated, if cookies are not saved,
    what happens with the web pages or website? Can the website operate if the user
    doesn't allow cookies?

    Can the site be used without cookies? I guess that is my question.

    Let us know, and we'll provide a script to accept or deny cookies ... but it will
    still use one cookie to remember that (which is legal in this case).

    EDIT:
    And an fyi ... your site looks horrible with the main top banner being a warning about cookies.
    That's not the way to design a website. Most users will click away as soon as they see that.
    I think that top part about cookies will destroy the site (visitor count, ranking, etc) completely.

    But, if that's what your client wants, that's his problem.
    A bad way to do business for a car company.


    .
    Last edited by mlseim; 06-10-2012 at 05:42 PM.

  • #12
    New Coder
    Join Date
    Jun 2012
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts
    If they don't want to use cookies then they can leave simple as, BUT if they carry on using the site then they agree to the use of cookies on that site as the warning states.
    Yes the site may look ugly with the banner at the top but it has to be in site when a user views any page, if they accept it disappears and stays hidden until they deletes cookies from their browser.
    It not something I would put on a website if I had the choice but I don't it has to have that or something similar by LAW it cannot just be stated in a terms and agreements section on the site, and most sites will have this or something similar now if they are in the EU.
    I have already seen several websites that have this, ugly or not it has to be done unless the owner wants a court summons and a fine of up to £500,000.

    If it is a bad way to design a website then how come companies like the BBC are using it???

    again here are some examples -
    http://www.bbc.co.uk/
    http://www.aboutcookies.org/
    http://www.skillcard.org.uk/

    PS - I appreciate your concerns and I don't mean to sound like I'm being argumentative about this but I don't want to discuss why they have brought this law in, what its doing or what the site looks like I just want help on sorting this issue out.

    Thanks again

  • #13
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    First you need to deal with the top banner itself.

    If they click NO, you need to have it go to a script called "nocookie.php".
    So, create that script and just put this in it for now.

    nocookie.php
    PHP Code:
    <?php
    $value
    ="N";
    setcookie("permission"$valuetime()+(3600*24*7));  /* expire in 1 week */
    header ('location: index.php');
    ?>

    Make it so that when they click "NO", the javascript will run that PHP script called "nocookie.php".

    Create another script called "yescookie.php";

    yescookie.php
    PHP Code:
    <?php
    $value
    ="Y";
    setcookie("permission"$valuetime()+(3600*24*14));  /* expire in 2 weeks */
    header ('location: index.php');
    ?>
    The yescookie.php script will execute after the confirmation box you made.


    At the top of your script that displays the permission box (banner), you'll
    need to see if the cookie called "permission" exists, and if it does, is the value "Y"?

    If the value is "Y", you won't display that banner.
    After 2 weeks, the banner will reappear, because the cookie is erased.

    top of scripts
    PHP Code:

    <?php

    if(isset($_COOKIE['permission'])){

    if(
    $_COOKIE['permission']=="Y"){
    // Permission to accept cookies
    // so don't display the banner.
    // Maybe let them know they are getting cookies?
    // (banner won't appear)
    }
    else{
    // 
    // No permission to accept cookies
    // You can display something that tells
    // them they won't be getting any cookies.
    // (banner won't appear)
    }

    }
    else{
    // display the banner here
    // banner stuff

    // (banner will be appearing here)
    }


    // the rest of your script here ...

    // Every other place in your website where you will be writing a cookie,
    // you'll need to recheck $_COOKIE['permission'] to make sure the value is "Y"
    // before you write any other cookies.

    ?>
    Last edited by mlseim; 06-10-2012 at 08:17 PM.

  • Users who have thanked mlseim for this post:

    Pezmo82 (06-10-2012)

  • #14
    New Coder
    Join Date
    Jun 2012
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Ok I've created a file called nocookie.php and yescookie.php and placed the other code where the banner will be including the banner in the code.

    I've searched for how to get javascript to run this php function and I'm stuck again. but I thought I'd try typing the url with yescookie.php on the end and the banner does not display at all even when refreshed which is a good sign just need to find the javascript code to run onclick.

    Thanks soooo much mlseim
    Last edited by Pezmo82; 06-10-2012 at 09:28 PM.

  • #15
    New Coder
    Join Date
    Jun 2012
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts
    ALL SORTED YAY

    Thanks again mlseim


  •  

    Tags for this Thread

    Posting Permissions

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