100% found this document useful (1 vote)
278 views11 pages

PHP State Management

PHP provides two state management techniques to overcome the stateless nature of HTML and web interactions: cookies and sessions. Cookies are files stored on the user's browser that can store small amounts of data and are sent back to the server on subsequent requests, but have security and storage limitations. Sessions store data on the server, allowing more data to be stored more securely than cookies, but require a session ID to link the user to their data on each request either through passing the ID in the URL or storing it in a cookie.

Uploaded by

Vishal Bhole
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
278 views11 pages

PHP State Management

PHP provides two state management techniques to overcome the stateless nature of HTML and web interactions: cookies and sessions. Cookies are files stored on the user's browser that can store small amounts of data and are sent back to the server on subsequent requests, but have security and storage limitations. Sessions store data on the server, allowing more data to be stored more securely than cookies, but require a session ID to link the user to their data on each request either through passing the ID in the URL or storing it in a cookie.

Uploaded by

Vishal Bhole
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

PHP State Management Techniques

HTML is a stateless technology, therefore a Web site, as a series of HTML pages, is also
stateless. This means that each interaction between the user (i.e., the Web browser) and the
server is a separate interaction, with no relationship to any other interactions. When a user is
viewing http://www.nusphere.com, then clicks on a link to go to
http://www.nusphere.com/download.php.ide.htm, those are two separate and unrelated
occurrences. This all might sound strange for unseasoned Web developers but it's important to
understand. In order to provide to the end user a seamless interaction, like the ability to log
into and access areas of a site, you must work around the stateless environment. PHP provides
two different state management techniques for overcoming the problems inherent in the
stateless Web. The first of these is the cookie. A cookie is a bit of information sent by a server
to the Web browser, where it resides. When the Web browser goes to any subsequent page in
that same domain, it provides to the server access to this same cookie. It's a simple and easy-
to-implement option. Cookies, though, are limited as to how much information they can store
and there are security implications involved. The second PHP state management technique is
the session. A session stores all of the data on the server. For this reason, sessions can be more
versatile and secure than cookies. The biggest potential problem with sessions is that they rely
upon a session ID: an identifier that points to each unique set of session data. This session ID
must be accessible on each page, either by passing it from page to page (which has its own
security concerns) or by storing it in a cookie.
Working with FTP in PHP
?>

You might also like