TAILIEUCHUNG - the book of javascript 2nd edition phần 6

Tham khảo tài liệu 'the book of javascript 2nd edition phần 6', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | -- hide me from older browsers Name cookie_information name br Age cookie_information age br Phone cookie_information phone br show me -- script body html Figure 12-6 Loading a complex cookie into an associative array When this page loads sets a cookie creates a new array and sends the new empty array to the readTheCookie function. The function first gets the cookie and splits off the cookie s name my_cookie . After the_values will equal name thau age just a tyke phone 411 because that s how we set the cookie in the setCookie function. Next splits the_values into its component parts loading name thau into separated_values 0 age just a tyke into separated_values 1 and phone 411 into separated_values 2 . After the function breaks up the_values loops through each of the three elements name age and phone in separated_values. Each time through the loop the function breaks the element into two pieces along the colon. It then loads the first part of the element into the_property and the second part into the_value. The first time through the loop the_property is name and the_value is thau . Once the element is split like this the associative array the_info gets loaded in . After the loop has occurred three times you get these results the_info name thau the_info age just a tyke and the_info phone 411 . With the associative array loaded properly the three lines starting in retrieve the information and display it on a web page. Setting the Duration of a Cookie Until now we ve been creating cookies that disappear when a user exits the browser. Sometimes this is for the best. Since each domain can have only 20 cookies on a user s machine you don t want to waste space by saving unnecessary cookies between browser sessions. However if you do want your cookies to remain on a user s hard drive after he or she quits the browser you have to set an expiration date in UTC format. For example Sun 12 Jan 1992 00 00 00 UTC is the supposed .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.