You can use this kind of code for user systems to check if a user is logged in or not. This is a very good checking to see if users have logged in or not.
PHP has a function setcookie since version 3.0, but this function is too low-level for simple usage.
Function ae_put_cookie provided, sets cookie for current domain without specifying long arguments lists. Just three arguments: 'name', 'value', session cookie flag/number of days/forever cookie flag
A collection of 23 tips on understanding and managing cookies in PHP. Clear explanations and tutorial exercises are provided on setting and receiving cookies, creating and removing persistent cookies, specifying domain and path to restrict cookies, finding cookies in cookie files, cookie limitations:
How To Send and receive a Cookie to the Browser?
How To Set a Persistent Cookie?
How To Remove a Cookie?
How To Specify Domain and Path for a Cookie?
How Cookies Are Transported from Servers to Browsers?
How To View Cookie Header Lines?
Where Are the Persistent Cookies Stored on Your Computer?
How To View the Content of a Cookie File?
How Many Cookies Can You Set?
How Large Can a Single Cookie Be?
How Are Cookies Encoded During Transportation?
How Can Other Webmaster Steal Your Cookies?
......
A collection of 19 tips on understanding and using sessions in PHP. Clear explanations and tutorial exercises are provided on starting and closing sessions, saving and retrieving values in sessions, deciding how session IDs to be transferred, deciding where to store session files, deciding when to expire session values, etc. Topics included in this collections:
What Is a Session?
How To Turn On the Session Support?
How To Save/Retrieve Values to the Current Session?
What Is a Session ID?
How To Retrieve the Session ID of the Current Session?
What Are the Options to Transfer Session IDs?
How Session IDs Are Transferred on Your Web Server?
How To Force the PHP Engine to Use Cookies to Transfer Session IDs?
Is It More Secure to Use Cookies to Transfer Session IDs?
Where Are the Session Values Stored?
What Set the Timeout Period on Session Values?
How To Remove Values Saved in the Current Session?
How To Tell If a Session Is New?
What Is session_register()?
Platform(s): Linux, Windows, FreeBSD, Mac OSX, Sun Solaris
A session is the time that a user spends at your Web site. Users may view many Web pages between the time they enter your site and leave it. Often you want information to be available for a complete session. Beginning with version 4.0, PHP provides a way to do this.
PHP allows you to set up a session and store session variables. After you create a session, the session variables are available for your use on any other Web page.
This script can display a form or the data stored inside cookies depending on whether cookies has been set or not.
The online form is used to send data and store them inside cookies.
The script contains an online example.