updating code for setting cookies according to session_id