You are invited to Log in or Register a free Frihost Account!

Introduction To Cookies :

What is a cookie?

As defined by a cookie is described as:
Computer Science: A collection of information, usually including a username and the current date and time, stored on the local computer of a person using the World Wide Web, used chiefly by websites to identify users who have previously registered or visited the site.

Cookies basically store information on a user, you must have seen those ‘Remember Me’ buttons on login forms, these forms set cookies on your hard drive with your username and password inside them (or any other information specified).

When a user visits your site you can store certain information about them, such as browser, IP address, operation system etc, but the problem with this is when the user comes back they may not have the same IP address (which is the most common way to recognise a user). By setting a cookie on a user’s computer it will remember that particular user when they return and read the information from it, even if the user has a different IP address (which is most likely).

What can you do with a cookie?

You can set a cookie on a user’s computer so that you can remember them when they return in the future … only problem being a lot of people delete their temporary internet files and cookies frequently because of clutter, this is why most webmasters set a time limit on their cookie to delete itself after an hour.

The PHP Manual has all the information you need on manipulating cookies in the set cookie function page but it is quite a read, I hope to simplify using cookies as much as possible.

Setting A Basic Cookie

To set a cookie on a user’s computer you would use the setcookie() function, using PHP it would look like this:

?> [/PHP]

Now to create a very basic cookie:

PHP Code:

This example would store the user's name in a cookie called 'Joe2Torials'. By setting cookies like this, you don't set any specific options, so by default the cookie will be available to the domain in which it was set (your site) and it would be deleted when the user closed the browser.[/quote]
Hi yimaw

can you teach me more about cookies i want to set cookie
couple of places to learn more
i want o that .well if i set cookies it wil collect all the information of the website user or visitor wel where it store it and show me the out put ?
Thank you.Now I know what is cookies.
That's not really secure as you aren't encrypting any data in that cookie nor are you inserting the password in the cookie either. Anyone can go and edit the cookie file, change the username, and walk into anyone's account. That is a nice introductory that cookies actually exist, but webmasters should really consider on making them a lot more secure on their websites.

- Mike.
Related topics
avoid super cookies
Basic HTML Introduction
recipie for chocolate chip cookies
PHP: Sessions and Cookies
PHP Tutorials
Flash Introduction
The Rare Breed: An Introduction.
Help for sending 2+ cookies in one page.
[php/cookies] poll on two sites
Give FRIH$ 5 and get 1 gmail invitation
PHPBB Cookies
Book on CSS
FireFox and Cookies/Sessions
using cookies in PHP
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

© 2005-2011 Frihost, forums powered by phpBB.