iSelfSchooling.com  Since 1999     References  |  Search more  | Oracle Syntax  | Free Online Oracle Training

    Home      .Services     Login       Start Learning     Certification      .                 .Share your BELIEF(s)...

 

. Online Accounting        .Copyright & User Agreement   |
    .Vision      .Biography     .Acknowledgement

.Contact Us      .Comments/Suggestions       Email2aFriend    |

 

What is a cookie?

What is a cookie?


A cookie is a tool for a server to store information about the user. The server utilizes it so that can remember the user’s data or information over the course of his/her visit or through several visits.

Also, you should have this in your mind that a cookie can only be used to store information or data that you provided to it. So, it is as secure as you give information to it. 

Creating cookies (cookie)
Use the setcookie (‘cookie name’,’cookie value’) function to send a cookie from a server to a user’s browser. 

The following is an example of a cookie in PHP. Write the code into a notepad and then save it as “gather_data.php” then upload it to your server or on your PHP enabled computer.

<?php
// always have your error handling turn on.
ini_set (‘display_errors’,1);
error_reporting (E_ALL & ~E_NOTICE);

// set a flag to indicate the status of cookies have been sent
$cookies = FALSE; // not sent yet.

// check your form that will prompt users
if (isset ($_POST[‘submit’])) {
// start sending the cookies - not more than 20.
setcookie (‘name’,$_POST[‘name’]);
setcookie (‘ssn’,$_POST[‘ssn’]);
setcookie (‘phone’,$_POST[‘phone’]);
setcookie (‘email’,$_POST[‘email’]);
$cookies = TRUE; // sent.
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitionl.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Provide us your information.</title>
</head>

<body>
<?php 
// if the cookies were sent, print a message.
if ($cookies) {
print ‘<p>Your information was received. </p>’;
}
?>

<form action=”gather_data.php” method=”post”>
Full Name: <input type=”text” name=”name” size=”45” /> <br />
Social Security number: <input type=”text” name=”ssn” size=”12” /> <br />
Phone: <input type=”text” name=”phone” size=”10” /> <br />
Email address: <input type=”text” name=”email” size=”45” /> <br />
<input type=”submit” name=”submit” value=”submit your information” />
</form>

</body>
</html>

 

 

Google
 
Web web site