Tikam Shah

What is difference between session and cookies in php ?

The Session allows you to store the piece of information just as the Cookie but the base difference between them is
  • The SESSION is stored at the server site where as the Cookies are stored at the client site i.e at the local machine of the user browser . 

  • The Cookie store the limited amount of data i.e  4kb   (4096bytes) approx Where as SESSION stores the unlimited part of information at server side .

  • Session : More  Secure  where as  Cookie : Less Secure .
  •   Setting Cookie time to expire the cookie where as  use session_destroy() function is used to destroy the session variable .
  • setcookie() function is used for initialisation of cookie where as session_start() function is used to start the session .