TAILIEUCHUNG - Học php, mysql và javascript - p 32

Mô tả Tên của cookie đó. Đây là tên mà máy chủ của bạn sẽ sử dụng để truy cập các cookie trên trình duyệt yêu cầu tiếp theo. Giá trị của cookie, hoặc nội dung của cookie. Điều này có thể chứa lên đến 4 KB của văn bản chữ số. (Tùy chọn) Unix dấu thời gian của ngày hết hạn. Nói chung, bạn có thể sẽ sử dụng thời gian () cộng với một số giây. Nếu không được thiết lập, cookie hết hạn khi trình duyệt đóng lại. . | Example 13-6. Retrieving session variables php session_start if isset _SESSION username username _SESSION username password _SESSION password forename _SESSION forename surname _SESSION surname echo Welcome back forename. br Your full name is forename surname. br Your username is username and your password is password . else echo Please a href click here a to log in. Now you are ready to call up into your browser enter a username of bsmith and password of mysecret or pjones and acrobat when prompted and click on the link to load in . When your browser calls it up the result should be something like Figure 13-5. Figure 13-5. Maintaining user data with sessions Sessions neatly confine to a single program the extensive code required to authenticate and log in a user. Once a user has been authenticated and you have created a session your program code becomes very simple indeed. You need only to call up session_start and look up any variables to which you need access from _SESSION. In Example 13-6 a quick test of whether _SESSION username has a value is enough to let you know that the current user is authenticated because session variables are stored on the server unlike cookies which are stored on the web browser and can therefore be trusted. If _SESSION username has not been assigned a value no session is active so the last line of code in Example 13-6 directs users to the login page at . Using Sessions 291 The program prints back the value of the user s password to show you how session variables work. In practice you already know 1 that the user is logged in so it should not be necessary to keep track of or display any passwords and doing so would be a security risk. Ending a Session When the time comes to end a session usually when a user requests to log out from your site you can use the session_destroy function in association with the unset function as in Example 13-7. That

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.