Forum Moderators: phranque

Message Too Old, No Replies

Setting up craigslist-style cookies.?

Cookies that auto-foward to previously viewed subdomains or directories.

         

balzahk

9:16 am on Jan 21, 2008 (gmt 0)

10+ Year Member



I want to set up a web site that has works kind of like craigslist.org.

What I am talking about is if you clear your cookies and go to craigslist.org, you will be brought to their main page with a list of all the locations. For instance, you click on "Denver" and it brings you to denver.craigslist.org.

Now, whenever you go to craigslist.org, you are automatically forwarded to denver.craigslist.org until you navigate to another location such as atlanta.craigslist.org and from that point on you are automatically forwarded to atlanta.craigslist.org.

I'm making sense, right?

Well, I am wondering how I could set this up. Basically, I want to have a site that will have different locations that the user can click on and once that person clicks on a location, whenever they go to the main site again they will automatically be forwarded to the site for that location. It will either be location.domain.com or domain.com/location, it doesn't really matter to me at the moment if I use a subdomain or a subdirectory.

What is the easiest and least technical way to do this for someone who is unfamiliar with programming languages?

Thanks in advance.

rocknbil

4:53 pm on Jan 21, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard balzahk, this indeed will require **some** form of programming work.

The best is server side, but it can also be done with Javascript. That will always show the main page first, then redirect via location. It will also fail if Javascript is disabled.

The logic is pretty simple:

if ($my_cookie && ($my_cookie!= '')) {
[send to page with value of my_cookie]
}

You may even be able to do this using mod_rewrite, but I have never heard of it manipulating redirection based on a cookie. You can ask in the Apache forum.