The main difference between cookies and sessions is that cookies are stored in the user's browser, and sessions are not.
A cookie can keep information in the user's browser until deleted.
Sessions work instead like a token allowing access and passing information while the user has their browser open. The problem with sessions is that when you close your browser you also lose the session.
I have read the very good post on cookies and sessions with suitable php code.You can see that in http://cs-pages.blogspot.com/2011/05/difference-between-cookies-and-sessions.html