you can store the session id, but a random number and a db entry would be better to store, then a db call can get the number and automatically log the user in
but to answer the question:
[man]setcookie[/man]
setcookie(mycookiename, $PHPSESSID, expire time, etc);