PHP Cookies:
Uses of Cookies:
Syntax for Create,Retrieve,Delete the Cookies:
Difference B/w Cookies&Session:
1.Cookies->store the information->remote browser(web Page). 2.Same user->comes back to page->same information retrived again.
Uses of Cookies:
1.Session management:Manage Session User 2.User identification:Once the User Visits the web Page,that the user Can be Remembered. 3.Tracking / Analytics:Ieentify/Track the user.
Syntax for Create,Retrieve,Delete the Cookies:
Create->setcookie(name, value, expire, path, domain, secure, httponly) Eg: <?php setcookie("myCookie", "PHP Tutorial", time()+3600, "/tutorials"); ?> Retrieve-> <?php echo "The cookie value is ".$_COOKIE['myCookie']; ?> Delete-> <?php setcookie("myCookie", "", time()-60); ?>
Difference B/w Cookies&Session:
1.Both cookies and sessions are used for storing persistent data. 2.Sessions are stored->server side. Cookies->client side. 3.Sessions are closed when the user closes his browser. For cookies, you can set time that when it will be expired. 4.Sessions are safe that cookies. Because, since stored on client's computer, there are ways to modify or manipulate cookies. 5.Cookie is stored on your computer, and a session is not.
Good post on cookies, if any one not know the fact please go through it.
ReplyDeleteOutsource PHP Development by xicom technologies