---
title: "Sätt Cookie"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/64306-sätt-cookie"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "Asa"
published: "2003-01-09T12:30:15.000Z"
updated: "2003-01-12T15:03:52.000Z"
replies: 2
views: 284
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/php/64306-sätt-cookie"
---

# Sätt Cookie

## #1 — Asa, 2003-01-09T12:30Z

Bygger en poll och undrar hur jag sätter en cookie för varje fråga?
Jag skickar med pollId i querystringen. Ex vote.php?pollId=1&svar=2

Nuvarande kod:

```
<?require ("./inc/settings.php");

$conn_poll = mysql_connect("$server", "$anvandare", "$losen");
mysql_select_db("$databas");

if($HTTP_COOKIE_VARS['cookieSet'] != "voted") {
     mysql_query("Update svar Set klick=klick+1 WHERE id = '$svar'");
     $time = (time()+$cookietid);
     setcookie("cookieSet", "voted",$time); 
}
If ($typ == "old"){
  header ("Location: oldpoll.php");
}else{
  header ("Location: $sidan");
}?>
```

Permalänk: https://www.webforum.nu/p/64306

## #2 — Asa, 2003-01-09T13:06Z

Jag fick till det:

```
<?require ("./inc/settings.php");

$conn_poll = mysql_connect("$server", "$anvandare", "$losen");
mysql_select_db("$databas");

if ($HTTP_COOKIE_VARS["cookieSet$pollId"] != "") {
} else {
     mysql_query("Update svar Set klick=klick+1 WHERE id = '$id'");
     $time = (time()+$cookietid);
     setcookie ("cookieSet$pollId", "voted",$time);
}
If ($typ == "old"){
  header ("Location: oldpoll.php");
}else{
  header ("Location: $sidan");
}?>
```

Permalänk: https://www.webforum.nu/p/908314

## #3 — WiZzLeR, 2003-01-12T15:03Z

hehe

Permalänk: https://www.webforum.nu/p/910455

---

Tråden på webben: https://www.webforum.nu/amne/php/64306-sätt-cookie
