Hi all, Could anybody tell me exactly when to use session and when to use cookie with example. Thank you all.
Sessions are to be used for data that the user should not be able to tamper with. It's more secure. Things like access level, user id and so on.
Very good explanation premiumscripts. I would add just that sessions are for many data, of many types, cookies just for few data, and not of complex types. also remember that cookies are in the client computer. if you make them big the site load time will be great too.
You can use session for storing Id or secured elements. And in case of no security issue like storing the products, n all in shopping sites you can go through cookie.