What is the different between cookies and session in php?

Answer Posted / vivek srivastava

Sessions: are basically tokens which are generated when a
user proceeds with a login mechanism. Each time when a user
logged into a website a new and unique token is generated
and it will destroyed whenever he/she logged out from that
site or power goes off. However, session information is
temporary and will be deleted after the user has left the
website.

Cookies:are temporary files which are store in users hard
disk. A cookie is often used to identify a user. Suppose a
user enters into a website and without logging off he/she
closed the page, next time when he/she open the page he/she
found himself/ herself logged in. This is because of
cookies, they store the user information. We can set the
cookies by <b>setCookie()</b> function. The syntax if
setCookie function is <b>setCookie(name, value, expire,
path, domain);</b>.

Is This Answer Correct ?    30 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to create a session? How to set a value in session?

499


How to assigning a new character in a string using php?

527


Explain how is it possible to set an infinite execution time for php script?

488


What is htmlspecialchars?

527


What is the scope of a variable defined in a function?

538






What does nan stand for computer science?

481


What is the difference between for and foreach in php?

476


Why php 7 is faster?

487


What is singleton class in php?

516


Which programming language does php resemble?

517


What is the use of strip_tags() method?

527


What is the difference between array_merge() and array_merge_recursive() in php?

524


What is difference between require_once(), require(), include()?

500


What is cookie?

514


What is the difference between for and foreach loop in php?

604