Results 1 to 2 of 2

Thread: Set Cookie Redirect

  1. #1
    Join Date
    Jun 2011

    Set Cookie Redirect

    Would someone show me how to set cookie redirect like craigslist site?

    For example, if I go to craigslist site (http://www.craigslist.org/about/sites/) and click "auburn" under Alabama it will take me to auburn.craigslist.org page. If I exit then go back to craigslist.org it automatically redirect me back to auburn.craigslist.org page.

  2. #2
    Join Date
    May 2011
    With Hobbits
    Yeah, just give a cookie upon selection.

    So you would have a select box like so.

    HTML Code:
    <select name="location">
    <option value="GA">Georgia</option>
    <option value="AL">Alabama</option>
    Than in php you have.
    PHP Code:
    time() + 50400;  //Time you want the cookie to last, currently 14 hours
    setcookie(My_Site_Location$_POST['location'], $hour);
    Than at the head of your page you check and redirect

    PHP Code:

    if (empty(
    header("Location: Website.com/index.php"); 
    } else {
    header("Location: Website.com/$Loc.php"); 
    Something to that effect not sure if that 100% correct but it should get you in the right direction.
    Albert Einstein ~ "Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction."

    Things To help you on this Site

    1. Place all php code in [php] Tags
    2. Place all html code in [html] Tags
    3. Remember to mark all your Threads Resolved using thead tools at the top when your problem is solved

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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