10/10/2018, 09:34

mình không xóa cookie được

mình viết trang logout.php có nội dung sau:
if(isset($_COOKIE['islogin']))
{
echo $_COOKIE['islogin'];
setcookie('islogin');
echo $_COOKIE['islogin'];//kiểm tra thử còn cookie hay không
}
kết quả cookie không bị xóa, mong các pro trên diễn đàn chỉ giúp
kenphan19 viết 11:47 ngày 10/10/2018
tớ chả phải pro gì nhưng chắc có thể giúp câụ ...
Trước tiên câụ phải hiêủ cookie cái đã .
setcookie(name, value, expire, path, domain);
name : tên cookie.
value : nội dung cookie
exprire : thơì gian hết hạn.
path : đường dẫn cookie.
domain : domain của site bạn.

để tạo cookie
setcookie("user", "Alex Porter", time()+3600, "path/cookie");

nêú muốn xóa cookie thì
setcookie("user", "", time()-3600, "path/cookie");

lưu ý nêú bạn xóa cookie ... setcookie("user", "Alex Porter", time()+3600, "path/cookie"); thì bạn phải chọn đúng cái path lúc khởi tạo cookie setcookie("user", "Alex Porter", time()-3600, "path/cookie");
BossFTP viết 11:50 ngày 10/10/2018
PHP Code:
//từ chỗ này trở lên ko echo, print gì hết
if(isset($_COOKIE***91;'islogin'***93;))
{
// echo $_COOKIE***91;'islogin'***93;; // bỏ dòng này đi.
setcookie('islogin');
echo 
$_COOKIE***91;'islogin'***93;;//kiểm tra thử còn cookie hay không


[=========> Bổ sung bài viết <=========]

Like other headers, cookies must be sent before any output from your script (this is a protocol restriction). This requires that you place calls to this function prior to any output, including <html> and <head> tags as well as any whitespace.
quangdongst viết 11:50 ngày 10/10/2018
cho minh hoi them cach upload tap tin len mot thu muc minh phai lam nhu the nao? code don gian thoi nha, con rau ria minh tu lam
hp911 viết 11:50 ngày 10/10/2018
Gồm 2 File


function upload_file()
{
?>
<table width="70%" border="1" align="center" bordercolor="#00FFFF">
<tr>
<td><form enctype="multipart/form-data" action="action_class.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form></td>
</tr>
<tr>
<td>File Sẽ Được Tự Động Đưa Vào Thư Mục download/ </td>
</tr>
</table>


<?php

}



File action_class.php



<?php
/*------------------------------------Upload_File----------------------------------*/
$target_path = "download/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))
{
echo "File: ". basename( $_FILES['uploadedfile']['name'])." File Đã Đựơc Lưu Vào Thư Mục download/";
echo "The file ". basename( $_FILES['uploadedfile']['name']).'<p><a href="admin_full.php">Click here to Admin</a> </p>';
}


?>
Bài liên quan
0