SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: cookies

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Apr 2010
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    cookies

    I have a homepage which has a script with a function which as well as other things, sets a cookie to true.

    The homepage has an into and setting the cookie to true makes sure that the intro doesn't display again if the user goes to another page and then returns to the homepage. However, if the user visits another site and then returns to the site I would like the intro to show again. At the moment it doesn't. Is there any way to ensure this happens?

  2. #2
    SitePoint Zealot Sogo7's Avatar
    Join Date
    May 2011
    Posts
    129
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    It could be done with a cookie however it's a bit of a legal minefield at the moment for UK websites.
    For those not familiar watch this: http://www.youtube.com/watch?v=arWJA0jVPAc
    Most webmasters are ignoring it but it's an uneasy standoff and many eyes are watching what other .gov sites decide to do as many of them are not wholly complient either.

    Would suggest using the 'referer' element, this will tell you what domain the visitor came from eg: Google,Bing, Yahoo etc or yoursite.co.uk
    the logic being in the referer value is anything other than your website then show the welcome message.

    Code:
    <SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
    <!-- Hide script from old browsers : place inside the BODY tags
      if (document.referrer != 'yoursite.co.uk')
    document.write('Hello and welcome blah,blah,blah ');
    //-- Stop hiding script -->
    </SCRIPT>
    Lovelogic.net Personal Projects Pit - Spammers welcome


Bookmarks

Posting Permissions

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