Cookies

There are about a million ways to set and parse cookies, and every browser handles them differently. Spent all day doing PHP cookie tricks for user authorization for our intranet. Think I finally nailed it for all browsers. Days like this, you want to pull out your hair (or pull *some*one’s hair anyway). Then when you’re done there’s this great satisfaction.

I break horses… ( – smog )

2 Replies to “Cookies”

  1. Hacker, sir ~!

    I’ve been glancing around your blogs etc and find your entries very interesting indeed, I am a MAC OS X nerd and am interested in all the stuff you are doing – streaming iTunes, etc.

    I read your “Server It Up” article and that got me up and running on PHP/MySQL. Now I am attempting to set cookies for the login admin section. Can you point me in the right direction? Or tell me what your solution was above to make browser compatible cookies? Obi wan, you’re my only hope, etc etc …

    thanks,

    Brent

  2. Hi Brent – It’s nothing too fancy. This is what I’m currently using:

    if (!some_cookie) {
    setcookie (“some_cookie”, $type,time()+60000000, “/”, “”, 0);

    header(“Location: /?”);
    exit;
    }

    Where $type is one of many user types with varying permissions levels. After successfully setting the cookie the user is returned to the homepage of the site.

Leave a Reply

Your email address will not be published.