Page 1 of 4 123 ... LastLast
Results 1 to 10 of 38

Thread: language cookie

  1. #1
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    927
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default language cookie

    Hey,
    On lots of sites, at your first visit, you have to chose your language. That information is stored in/by a cookie, so the next time you visit that site, you are immediately forwarded to the language you choose.

    How does such a cookie look like ? Is this php or Java ?

  2. #2
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    PHP or Java*Script.
    PHP is super easy to make cookies...
    See here:
    Code:
    setcookie(cookiename,data,time()+3600);
    and to retrieve like so
    Code:
    $_COOKIE[cookiename];
    - Mike

  3. #3
    Join Date
    Jul 2006
    Posts
    95
    Thanks
    21
    Thanked 0 Times in 0 Posts

    Default

    May I know if it is possible to create cookies so that I could track what people are doing on my site, such as downloading photos, songs, the page they view etc?

  4. #4
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    On every page,

    PHP Code:
    $cookiename "tracker";
    $olddata $_COOKIE[$cookiename];
    $newdata "Visited page " $_SERVER['PHP_SELF'];
    $data $olddata $newdata;
    setcookie($cookiename,$data,time()+3600); 
    Last edited by tech_support; 01-15-2007 at 01:22 AM. Reason: My bad.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  5. #5
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Quote Originally Posted by tech_support
    Code:
    setcookie(cookiename,data,time()+3600);
    This should actually be like this:

    Code:
    setcookie($cookiename,$data,time()+3600);
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  6. #6
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Oops... My bad.
    Fixed now.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  7. #7
    Join Date
    Jul 2006
    Posts
    95
    Thanks
    21
    Thanked 0 Times in 0 Posts

    Default

    Many thanks for both your help.
    After that, how do I retreive the record to check?
    Is it possible to tell the location (such as ip) of each person?

  8. #8
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  9. #9
    Join Date
    Jul 2006
    Posts
    95
    Thanks
    21
    Thanked 0 Times in 0 Posts

    Default

    Thanks but is there one that can combine with the above code?
    I only need to know the IP of the person.

  10. #10
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    PHP Code:
    $ip $_SERVER["REMOTE_ADDR"
    Last edited by tech_support; 01-15-2007 at 02:38 AM. Reason: I thought I done that...
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

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
  •