Thank you for the reply but cookie and session both are used to store information apart cookie is stored at client side whereas session is stored at server side but my question is what information we store in cookie and what information we store in session?
Typically the server-side session is used to store the state of user interactions on a website, for example shopping cart data. The server-side session is identified by a unique id (JSESSIONID), which is typically stored in a client-side session cookie. Unless the browser doesn't support cookies, in which case it ends up the URL. There are many other uses for client-side cookies though, but session tracking is one of the most common.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
For your better understanding, Say if you are logging into a mail account , Once you provide the username and password the data will reach the mail server as a response it sends an information like identification of your IP, date time so on all these will be stored in the cookie with the Unique id given to you. this (cookie file) can be viewed in your system too.
on other part session is like say after you logged in you might see your username across different pages like inbox, sent items, trash so on here your username will maintained by the session until you sign out This is called session