View Full Version : making first cookie
Irishcash33
02-22-2011, 07:19 PM
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
Beverleyh
02-22-2011, 07:43 PM
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?
Irishcash33
02-22-2011, 07:59 PM
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
bluewalrus
02-22-2011, 08:53 PM
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.