Blog

Easiest way learn about cookies in php

COOKIES:

  • cookies is a most important concept in web technologies.
  • It is client side process, this is small text files stored on the client side and it can be used for tracking purpose.
  • cookies can only store in strings value.
  • It is also called web cookie, Internet cookie, Browser cookie.

HOW TO SET A COOKIES:

  • Cookies created with the use of setcookie( ) function.
  • server send a  set of cookies to the browser.

syntax

        setcookie (name, value, expire, path, domain, secure, HTTP only);

  •  After setting a cookie it can be changed by a user in CREATE, MODIFY  and DELETE.


SAMPLE PROGRAM:

<?php

session_start();

?>

<!DOCTYPE html>

<html>

<body>

<?php

$_session[“favourite_fruit”]=”Mango”;

$_session[“favourite_vegetables”=”Tomoto”;

echo “session is successfully set”;

?>

</body>

</html>

Output

 

 

USES OF COOKIES:

Session management:

  1.  Cookies are widely used to manage user sessions.Cookies are used a lot in web applications to personalize response based on your choice or to keep track of session.session management widely used in the Authentication process.
  2. Session state is better security and More resource consumption of the server.

 

 User identification:

  • Cookies used on client side validation process.So the user and server are intermediate any third party or hacker entered at a time cookies are data caught and stored. After the stopped the sending process to the user and alerted the security message.

working:

  • cookies are created by client-side and stored to the server browser side.

Client side                                           Server side

  • widely cookies using in catch the user input data after then authentication by the server side.Server side identifies the user and after successful completion of authentication data are sent to the browser or user.

 

 

 

 

 

 

 

 

 

 

Leave a Reply

Your email address will not be published.