Results 1 to 4 of 4

Thread: making first cookie

  1. #1
    Join Date
    Jul 2008
    Location
    boston, ma
    Posts
    88
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default making first cookie

    Hi Guys,
    This is my first attempt at making a cookie. I have read a bunch of beginner tutorials. They seem too simple for what I need it to do.
    I have a landing page with 3 links on it. They each go to a different site. What needs to happen is when a user comes back after the first time the site remembers them and what they clicked the first time and redirects them to that site.

    So I go to www.site.com and click on siteurl2.com. The second time I go to www.site.com it should automatically go to siteurl2.com.

    Should be doable with a cookie right?
    Can anyone point me in the right direction?

    Thanks
    Will

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    For what reason do you need a redirect?

    I only ask because it might not be necessary. For example, on education sites you sometimes get a landing page asking who you are - a student, a teacher or parent - and from there you're directed to content that is more suitable to your genre. BUT cookies arnt used to solidify the choice.

    What if the user picks the wrong link in the first instance? Have they got a way of cancelling their choice?

    Personally I wouldnt mess with navigation but itsd something that you need to decide for sure.

    If the reason for a redirect is non-critical I wouldn't personally bother - not with a cookie anyway. If you consider that a cookie is stored on the local machine, you'd be affecting the choice of subsequent users too.

    I'd be tempted to suggest that a simple login system might be the way to go - its a more reliable way to deliver user-specific content as the data is serverside but that's another thing for you to weigh up and hinges on the type of content and reason for you redirect.

    Anyway, you've probably got a few more things to think about so I'll leave it with you.

    Maybe you could elaborate more on the reason for your redirect and others can offer their opinion?
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. #3
    Join Date
    Jul 2008
    Location
    boston, ma
    Posts
    88
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default

    Thanks Beverley,
    The education example is exactly what I am trying to do. On the landing page I have 3 choices; Banking Expert, Insurance Expert, and Securities expert.
    The links go to that specific content. Like how UPS.com does their site. You select a country and go to that country's site. When you go back to UPS.com, you are automatically brought to the country you selected site.

    I assumed it was a cookie to remember your choice. I couldn't find any other way that was close.

    Thanks
    Will

  4. #4
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Yes, it is a cookie.

    http://php.net/manual/en/function.setcookie.php

    If a cookie is created on the http://site.com and the user then loads http://www.site.com the cookie won't passover so you should either force the user to www., http, or make pages accessible without the cookies as well. The cookie won't be accessible when it is created but on loads after.
    Corrections to my coding/thoughts 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
  •