쿠키 + php 같이 쓰는법즘 정보
쿠키 + php 같이 쓰는법즘-
Terrorboys 자기소개 아이디로 검색 회원게시물
- 1,968

본문
echo "쿠키가 없데요~"; // 쿠키출력
setcookie("event_open", "123");
이렇게 했더니 헤드 쓰라고 머라고 하네요..
Warning: Cannot modify header information - headers already sent by
setcookie("event_open", "123");
이렇게 했더니 헤드 쓰라고 머라고 하네요..
Warning: Cannot modify header information - headers already sent by
댓글 전체
반대로 하세용 ;;
setcookie("event_open", "123");
echo "쿠키가 없데요~"; // 쿠키출력
쿠키나 세션 전에는 어떤 echo 문이나 html 공백 문자도 와서는 안됩니다 ;;
setcookie("event_open", "123");
echo "쿠키가 없데요~"; // 쿠키출력
쿠키나 세션 전에는 어떤 echo 문이나 html 공백 문자도 와서는 안됩니다 ;;
음 예제를 php.net 에서 들고와서 하나 적고 점수도 하나 --ㅎ;;
<?php
// set the cookies
setcookie("cookie[three]", "cookiethree");
setcookie("cookie[two]", "cookietwo");
setcookie("cookie[one]", "cookieone");
// after the page reloads, print them out
if (isset($_COOKIE['cookie'])) {
foreach ($_COOKIE['cookie'] as $name => $value) {
echo "$name : $value <br />\n";
}
}
?>
위 예제의 출력:
three : cookiethree
two : cookietwo
one : cookieone
<?php
// set the cookies
setcookie("cookie[three]", "cookiethree");
setcookie("cookie[two]", "cookietwo");
setcookie("cookie[one]", "cookieone");
// after the page reloads, print them out
if (isset($_COOKIE['cookie'])) {
foreach ($_COOKIE['cookie'] as $name => $value) {
echo "$name : $value <br />\n";
}
}
?>
위 예제의 출력:
three : cookiethree
two : cookietwo
one : cookieone
ob_start(); // php 와 쿠키 동시에 쓸경우 에러 나는것을 잡아준다.
echo "쿠키가 없데요~"."<br>"; // 쿠키출력
echo "<input type=button value='1' onclick=\"setCookie('event', '');\">";
echo $HTTP_COOKIE_VARS[event]; // 쿠키출력
이렇게 하면 같이 써도 되네요 ㅋㅋㅋ
echo "쿠키가 없데요~"."<br>"; // 쿠키출력
echo "<input type=button value='1' onclick=\"setCookie('event', '');\">";
echo $HTTP_COOKIE_VARS[event]; // 쿠키출력
이렇게 하면 같이 써도 되네요 ㅋㅋㅋ
버튼으로 쿠키 추가는 지금 찾는중이에요 무시하세요