TAILIEUCHUNG - Beginning PHP6, Apache, MySQL Web Development- P15

Beginning PHP6, Apache, MySQL Web Development- :Welcome to Beginning PHP6, Apache, MySQL Web Development , your new trusty resource for assistance in creating your own dynamic web sites. There are a lot of technologies available that can be used to deliver great web sites, and we ’ re glad you chose the Apache/MySQL/PHP (sometimes referred to simply as AMP) approach. You may or may not have had a taste of these three components in the past, but either way we ’ re confident that you will be impressed with the power that lies within them | Chapter 12 User Logins Profiles and Personalization The Set Cookies link directs you to which does just what the name says It sets cookie variables named username and remember_me which are just hard-coded in this example. It then uses a header redirect to send you back to the main test page. Figure 12-16 shows cookies_set .php in action. Figure 12-16 You can then navigate to . This page checks to see if the cookie values are valid. If they are not it says No cookies are set and you can try to set the cookies again. If the cookies were set successfully then the screen will look like the one in Figure 12-17. 391 Part II Comic Book Fan Site Figure 12-17 Try closing out your browser and then reopening it to visit again. You ll see that the cookies are still active. The cookies are set to expire 30 days from when they were set. If you want to delete them you can visit the Delete Cookies link. It calls which expires the cookies by setting their expiration date in the past and blanking out their values. Remember that cookie information is exchanged within HTTP headers cookies must be sent before the script generates any output. If you look at the documentation for the setcookie function you will see that it can accept more arguments than what we ve given it in this simple test. In addition to the information it stores each cookie has a set of attributes an expiration date a valid domain a valid domain path and an optional security flag. These attributes help ensure that the browser sends the correct cookie when a request is made to a server. The expiration time is used by the browser to determine when the cookie should be deleted. It is expressed as a UNIX timestamp plus the number of seconds before the cookie expires. 392 Chapter 12 User Logins Profiles and Personalization The valid domain is a partial or complete domain name to which the cookie will be sent. For example if the value for the valid domain

TỪ KHÓA LIÊN QUAN
TÀI LIỆU LIÊN QUAN
19    14    0
182    11    0
138    4    0
3    5    0
142    10    0