Você está na página 1de 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
?>

Você também pode gostar