read the column (see on the left columns) about secure user authentication.
Though I doubt if it is realy secure (see post of 3 days ago) since cookies are "spoofable" and/or copyable (on a public terminal or network), it works pretty good.
Another way of doing it is by setting a session cookie, inserting the set-time in a database along with its value and checking each time whether or not the value has expired. That's the way I do it. However, this is hard for you db!