Học php, mysql và javascript - p 31

Thiết lập một Cookie Để cài đặt một cookie trong PHP là một vấn đề đơn giản. Khi không có HTML vẫn chưa được chuyển giao, bạn có thể gọi hàm setcookie, trong đó có cú pháp sau đây (xem bảng 13-1): setcookie (tên, giá trị, hết hạn, đường dẫn, tên miền, an toàn, httponly); | Setting a Cookie To set a cookie in PHP is a simple matter. As long as no HTML has yet been transferred you can call the setcookie function which has the following syntax see Table 13-1 setcookie name value expire path domain secure httponly Table 13-1. The setcookie parameters Parameter Description Example name The name ofthe cookie. This is the name that your server will use to access the cookie on subsequent browser requests. username value The value of the cookie or the cookie s contents. This can contain up to 4 KB of alphanumeric text. Hannah expire optional Unix timestamp of the expiration date. Generally you will probably use time plus a number of seconds. If not set the cookie expires when the browser closes. time 2592000 path optional The path ofthe cookie on the server. Ifthis is a forward slash the cookie is available over the entire domain such as . If it is a subdirectory the cookie is available only within that subdirectory. The default is the current directory that the cookie is being set in and this is the setting you will normally use. domain optional The Internet domain of the cookie. If this is the cookie is available to all of and its subdomains such as and . If it is the cookie is available only to and its subdomains such as but not say to . . secure optional Whether the cookie must use a secure connection https . If this value is TRUE the cookie can be transferred only across a secure connection. The default is FALSE. FALSE httponly optional implemented since PHP version Whether the cookie must use the HTTP protocol. If this value is TRUE scripting languages such as JavaScript cannot access the cookie. Not supported in all browsers . The default is FALSE. FALSE So to create a cookie with the name username and the value Hannah that is accessible across the .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
125    158    1    14-05-2024
Đã 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.