VGP-BPS13-S
Would you like to react to this message? Create an account in a few clicks or log in to continue.


VGP-BPS13-S
 
HomePortalLatest imagesSearchRegisterLog in

 

 Developing State-enabled Applications With PHP

Go down 
AuthorMessage
Admin
Admin



Posts : 341
Join date : 2011-09-04

Developing State-enabled Applications With PHP Empty
PostSubject: Developing State-enabled Applications With PHP   Developing State-enabled Applications With PHP I_icon_minitimeThu Sep 08, 2011 12:33 pm

Installment 1
Developing State-enabled Products With PHP
When a user is evaluating a website and is surfing derived from one of web page to a different, sometimes the website is required to remember the actions (e. g. choices) performed by a computer owner. For example, in your website that sells DVDs, the user typically browses through a list of DVDs and selects private DVDs for check out when they get home of the shopping program. The website needs to reflect upon which DVDs the user has selected because the selected items needs to be presented again to you when the user assessments out. In other thoughts, the website needs to remember the State - that i. e. the selected items - of the user's browsing activities.
However, HTTP is a Stateless protocol as well as being ill-equipped to handle Declares. A standard HTML webpage basically provides information to the user and a series of links that simply directs you to other related internet pages. This Stateless nature of HTTP allows the website to be replicated all over many servers for pack balancing purposes. A major drawback is definitely that while browsing from a single page to another, the website does not remember the state of the browsing appointment. This make interactivity almost impossible.
In order to maximize interactivity, the developer can use the session handling features about PHP to augment the particular features of HTTP in order to remember the State of your browsing session. The happen to be basically 2 ways PHP does this:
The next installment discusses easy methods to manage sessions using biscuits...
Installment 2
Cookies
Cookies are used to store State-information during the browser. Browsers are allowed to keep up to 20 cookies every domain and the values stored while in the cookie cannot exceed 4 KB. If more than 20 cookies are produced by the website, only the latest 20 are stored. Cookies are only suitable in instances that not require complex session communications and are not favoured by some developers owing to privacy issues. Furthermore, some users disable support to get cookies at their surfers.
The following is a typical server-browser sequence of events that occur any time a cookie is used:
PHP provides a function called setcookie() to give easy creation of biscuits. The syntax for setcookie is definitely:
int setcookie(string name, [string val], [int expiration_date], [string path], string domain, [int secure])
The ranges are:
The following is definitely example that displays to the user how many times a specific web page has been displayed for the user. Copy the code listed below (both the php and the html) into a file with the. php extension and test it out.
The next installment discusses easy methods to manage sessions using PHP procedure handling functions with cupcakes enabled...
Installment 3
PHP Session Handling - Cookies Permitted
Instead of storing time information at the browser through the use of cookies, the information can instead be stored within the server in session computer files. One session file is created and maintained for each and every user session. For example, if there are three concurrent users browsing the web page, three session files will be created and maintained - one every user. The session files are deleted if the session is explicitly closed by way of the PHP script or by a daemon garbage collection process furnished by PHP. Good programming practice would call for sessions to be closed explicitly in the script.
The following may be a typical server-browser sequence regarding events that occur when a PHP session handling is required:
The following PHP session-handling example accomplishes similar outcome as the prior cookie example. Copy the code listed below (both the php and the html) into a file with the. php extension and test it out.
[?php //starts a session session_start(); //informs PHP that count information needs to be remembered in the session file if (!session_is_registered('count')) session_register('count'); $count = 0; else $count++; $session_id = session_id(); ?] [html] [head] [title]PHP Appointment Handling - Cookie-Enabled[/title] [/head] [body] The current session id is: [?=$session_id ?] This page has been displayed: [?=$count ?] times. [/body] [/html]
A summary of the functions that PHP offers up session handling are:
The next installment discusses how to manage sessions using PHP treatment handling functions when cupcakes are disabled...
Installment 3
PHP Session Handling - Without Cookies
If cookies are disabled at the browser, the above model cannot work. This is because although the session file that stores each of the variables is kept at the server, a cookie is still needed at the internet browser to store the session ID that is used to identify the session and its associated session file. The most common way around this can be to explicitly pass the session ID in to the server from the browser as a query parameter in the actual URL.
For example, the PHP script generates requests subsequent to the start_session call in the following format:
http: //www. yourhost. com/yourphpfile. php? PHPSESSID=[actual session ID]
The following are excerpts that illustrate a discussion:
Manually building the URL:
$url = 'http: //www. yoursite. com/yourphppage. php? PHPSESSID='. session_id(); [a href='[?=$url ?]']Anchor Text[/a]
Building the URL using SID:
[a href='http://www.yoursite.com/yourphppage.php?[?=SID ?]']Anchor Text[/a]





About the Author
John L is the webmaster of http: //www. bimmercenter. com..
daboss@bimmercenter. com
Back to top Go down
https://vgp-bps13-s.forumotion.com
 
Developing State-enabled Applications With PHP
Back to top 
Page 1 of 1
 Similar topics
-
» Modern day, a GPS-Enabled Fish Finder That Doesn't Hurt your wallet.

Permissions in this forum:You cannot reply to topics in this forum
VGP-BPS13-S :: Your first category :: Your first forum-
Jump to: