TAILIEUCHUNG - PHP & MySQL Everyday Apps for Dummies phần 4

Phần II: Xây dựng một ứng dụng User Authentication Các nhà xây dựngXây dựng bắt đầu phiên PHP. PHP session_start chức năng kiểm tra xem liệu một phiên đã tồn tại. Nếu không, nó bắt đầu một phiên làm việc mới. Nếu vậy, nó tiếp tục phiên họp hiện tại. Các nhà xây dựng không mong đợi bất kỳ thông tin nào được thông qua. | 116 Part II Building a User Authentication Application The constructor The constructor starts the PHP session. The PHP session_start function checks to see whether a session already exists. If not it starts a new session. If so it continues the existing session. The constructor doesn t expect any information to be passed. Thus the statement to create a Session object is sess new Session getVariabte This method returns the value of a stored PHP session variable. It checks whether the variable exists in the session. If it does the method returns the variable value. If the variable doesn t exist the method returns FALSE and stores an informative message. storeVariabfe This method stores a PHP session variable. The method expects two values a string that is the variable name and a value for the variable. The following numbers refer to line numbers in Listing 4-8 29 Begins an if block that executes when the first parameter is not a string. The block throws an exception with a message stating that the parameter is not a valid variable name. 35 Begins an else block that executes if the parameter is a string. The block stores the information in the _SESSION superglobal array and uses the variable name as the key. getMessage This method returns the contents of the message property. login This method logs an Account into the session. 44 Notice that the method expects two arguments an Account object and a string that is a password. The name of the object that is expected is included in the method signature. If acct is not an Account object a fatal error occurs as follows Fatal error Argument 1 must be an object of class Account in c on line 39 46 Calls the comparePassword method of the Account object that was passed to the login method. If the comparePassword method fails the login method returns FALSE. Chapter 4 User Login Application 117 47 If the comparePassword method does not fail the login method stores a PHP session variable called auth with a value of .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.