Wrong method for handling a password, if you keep a password in a cookie any time it got erased or intercepted in some way, don't do that. MWinter is 100% correct.
ASP
In ASP The "Response.Cookies" command is used to create cookies
The "Request.Cookies" command is used to retrieve a cookie value.
Writing a cookie, cookie name is user and cookie value is codeexploiter
Code:
<%
Response.Cookies("user")="codeexploiter"
%>
Reading a cookie
Code:
<%
username=Request.Cookies("user")
response.write("user name is " & username)
%>
Cookie with keys: creation
CODE]Response.Cookies("user")("fname")="Code"
Response.Cookies("user")("lname")="Exploiter"
Response.Cookies("user")("country")="India"
Response.Cookies("user")("age")="25"[/CODE]
Cookie with keys: reading
Code:
Response.write Request.cookies("user")("firstname")
Response.write Request.cookies("user")("lname")
Response.write Request.cookies("user")("country")
Response.write Request.cookies("user")("age")
If you want to learn how to set cookie using PHP then check the following
The setcookie() function is used to set a cookie.
Note: The setcookie() function must appear BEFORE the <html> tag.
Syntax
setcookie(name, value, expire, path, domain);
PHP Code:
<?php
setcookie("user", "codeexploiter", time()+3600);
?>
Retrieve a Cookie Value
The PHP $_COOKIE variable is used to retrieve a cookie value.
In the example below, we retrieve the value of the cookie named "user" and display it on a page:
PHP Code:
<?php// Print a cookieecho $_COOKIE["user"];// A way to view all cookies
print_r($_COOKIE);
?>
Here we check whether a cookies exist/has a value or not
PHP Code:
<?php
if (isset($_COOKIE["user"]))
echo "Welcome " . $_COOKIE["user"] . "!<br />";
else
echo "Welcome guest!<br />";
?>
If you want more details about this topic then refer PHP manual
Bookmarks