Cookies: BY Aravind, Helvin M Geevar, Sowmya, Thamjeeth, Saran
Cookies: BY Aravind, Helvin M Geevar, Sowmya, Thamjeeth, Saran
BY
Aravind,
Helvin M Geevar,
Sowmya,
Thamjeeth,
Saran
A cookie is a small file that the server embeds on the
user's computer. Each time the same computer requests
for a page with a browser, it will send the cookie too.
With PHP, you can both create and retrieve cookie values.
The setcookie() function is used to create cookies.
Note: The setcookie() function must appear BEFORE the
<html> tag.
This sets a cookie named "uname" - that expires after ten hours.
<?php setcookie("uname", $name, time()+36000); ?>
<html> <body> …
To access a cookie you just refer to the cookie name as a variable or
use $_COOKIE array
Tip: Use the isset() function to find out if a cookie has been set.
<html> <body>
<?php
if (isset($uname))
echo "Welcome " . $uname . "!<br />";
else
echo "You are not logged in!<br />"; ?>
</body> </html>
It will expire
or
Cookies must be deleted with the same parameters as they
were set with. If the value argument is an empty string (""),
and all other arguments match a previous call to setcookie,
then the cookie with the specified name will be deleted from
the remote client.
Session cookies
Stored only for the duration of a web-session.
Persistent cookies
Remain stored until they expire.
Server specifies optional domain.
Cookie gets sent with all requests to this domain.
Server specifies optional expiration date
Server can specify “secure” option:
Cookie is only sent when using SSL.
Version 0 cookies (Netscape cookies)
Session Hijacking
Counter measure:
Email messages.