Hallo,
mein Problem zu beschreiben bzw. an einem Code zu zeigen ist schwer da es ein laufendes Projekt ist. Aber ich versuche es mal.
Auf meiner Seite habe ich eine Bewertung die beim Laden der Seite angezeigt wird. Sobald ein User gevotet hat, wird ein Cookie (für 24 Stunden) gesetzt (mit PHP), sodass beim nächten Aufruf der selben Seite das Bewertungssystem nicht mehr angezeigt wird. Stattdessen ein Dankestext. Gesetzt werden die Cookies halt mir PHP und gelesen mir JS und eventuell das Bewertungssystem oder halt die Danksagung angezeigt. Das funktioniert auch sehr sehr gut.
Irgendwann hab ich ma n Besuchercounter gebastelt. Dafür speichere ich die IP und ebenfalls ein Cookie. Somit sind es schon beim laden der index zwei Cookies.
Der Counter funktzt super. Leider aber nicht mehr das Bewertungssystem.
Obwohl ein User gevotet hat, wird das ignoriert und trotzdem das Votesystem angezeigt.
Ich gehe mal davon aus, dass das JS damit nicht klar kommt. Warum?
hier kleine Schnippsel:
nun die .js datei die beim erneuten Laden der Index erkennen soll, dass bereits gevotet wurde und NICHT mehr das Voting anzeigen soll
Ach ja und bei Abgabe des Votes wird erneut ein Cookie gesetzt mit JS
Hat jemand bitte einen Rat? Danke.
mein Problem zu beschreiben bzw. an einem Code zu zeigen ist schwer da es ein laufendes Projekt ist. Aber ich versuche es mal.
Auf meiner Seite habe ich eine Bewertung die beim Laden der Seite angezeigt wird. Sobald ein User gevotet hat, wird ein Cookie (für 24 Stunden) gesetzt (mit PHP), sodass beim nächten Aufruf der selben Seite das Bewertungssystem nicht mehr angezeigt wird. Stattdessen ein Dankestext. Gesetzt werden die Cookies halt mir PHP und gelesen mir JS und eventuell das Bewertungssystem oder halt die Danksagung angezeigt. Das funktioniert auch sehr sehr gut.
Irgendwann hab ich ma n Besuchercounter gebastelt. Dafür speichere ich die IP und ebenfalls ein Cookie. Somit sind es schon beim laden der index zwei Cookies.
Der Counter funktzt super. Leider aber nicht mehr das Bewertungssystem.
Obwohl ein User gevotet hat, wird das ignoriert und trotzdem das Votesystem angezeigt.
Ich gehe mal davon aus, dass das JS damit nicht klar kommt. Warum?
hier kleine Schnippsel:
PHP-Code:
// in der INDEX über dem Header
$ip = $_SERVER['REMOTE_ADDR'];
setcookie("cook", "star", time()+60*60*24); // Cookies fürs Voting
// +++ ip filtern und cookie eintragen ANFANG +++
$ipcook = str_replace(".","",$ip);
$secbismorgen = (24*3600)- ((date("H")*3600)+(date("i")*60)+(date("s")));
setcookie("IP", $ipcook, time()+$secbismorgen); // Cookies fürn Counter
// --- ip filtern und cookie eintragen ENDE ---
PHP-Code:
setTimeout('check()',1000);
function check(){
if(document.cookie){
var cookie = document.cookie;
var cook = new Array(cookie);
var getrennt = cook[0].split(";");
if(getrennt[0] == "cook=star" && getrennt[1] == " box=kingsend"){
document.getElementById("voterahmen").innerHTML = '<table height="163" width="595"><tr><td id="option">Du hast bereits gevotet. Danke für deine Meinung!</td></tr></table>';
}
else if(getrennt[0] == "cook=star" && getrennt[1] != " box=kingsend"){
document.getElementById("voterahmen").innerHTML = '<form action="bewertung/" method="POST"><table height="163" width="595"><tr><td id="option">Übersichtlichkeit</td><td><img id="stern_1" src=" imgs/star_grey.png" alt="" onclick="highlight_star_fix1(this.id);" onmouseover="this.style.cursor=\'pointer\'; highlight_star1(this.id);" onmouseout="reset_fixed1();"><img src=" imgs/space.png"><img id="stern_2" src=" imgs/star_grey.png" alt="" onclick="highlight_star_fix1(this.id);" onmouseover="this.style.cursor=\'pointer\'; highlight_star1(this.id); " onmouseout="reset_fixed1();"><img src=" imgs/space.png"><img id="stern_3" src=" imgs/star_grey.png" alt="" onclick="highlight_star_fix1(this.id);" onmouseover="this.style.cursor=\'pointer\'; highlight_star1(this.id);" onmouseout="reset_fixed1();"><img src=" imgs/space.png"><img id="stern_4" src=" imgs/star_grey.png" alt="" onclick="highlight_star_fix1(this.id);" onmouseover="this.style.cursor=\'pointer\'; highlight_star1(this.id);" onmouseout="reset_fixed1();"><img src=" imgs/space.png"><img id="stern_5" src=" imgs/star_grey.png" alt="" onclick="highlight_star_fix1(this.id);" onmouseover="this.style.cursor=\'pointer\'; highlight_star1(this.id);" onmouseout="reset_fixed1();"></td><td id="b1" style="width:100px;color:#000000;font-size:15px; font-family:arial; font-weight:bolder;"></td><td></td></tr><tr><td id="option">Verlauf</td><td><img id="ster_1" src=" imgs/star_grey.png" alt="" onclick="highlight_star_fix2(this.id);" onmouseover="this.style.cursor=\'pointer\'; highlight_star2(this.id);" onmouseout="reset_fixed2();"><img src=" imgs/space.png"><img id="ster_2" src=" imgs/star_grey.png" alt="" onclick="highlight_star_fix2(this.id);" onmouseover="this.style.cursor=\'pointer\'; highlight_star2(this.id); " onmouseout="reset_fixed2();"><img src=" imgs/space.png"><img id="ster_3" src=" imgs/star_grey.png" alt="" onclick="highlight_star_fix2(this.id);" onmouseover="this.style.cursor=\'pointer\'; highlight_star2(this.id);" onmouseout="reset_fixed2();"><img src=" imgs/space.png"><img id="ster_4" src=" imgs/star_grey.png" alt="" onclick="highlight_star_fix2(this.id);" onmouseover="this.style.cursor=\'pointer\'; highlight_star2(this.id);" onmouseout="reset_fixed2();"><img src=" imgs/space.png"><img id="ster_5" src=" imgs/star_grey.png" alt="" onclick="highlight_star_fix2(this.id);" onmouseover="this.style.cursor=\'pointer\'; highlight_star2(this.id);" onmouseout="reset_fixed2();"></td><td id="b2" style="color:#000000;font-size:15px; font-family:arial; font-weight:bolder;"></td><td></td></tr><tr><td id="option">Zuverlässigkeit</td><td><img id="ste_1" src=" imgs/star_grey.png" alt="" onclick="highlight_star_fix3(this.id);" onmouseover="this.style.cursor=\'pointer\'; highlight_star3(this.id);" onmouseout="reset_fixed3();"><img src=" imgs/space.png"><img id="ste_2" src=" imgs/star_grey.png" alt="" onclick="highlight_star_fix3(this.id);" onmouseover="this.style.cursor=\'pointer\'; highlight_star3(this.id); " onmouseout="reset_fixed3();"><img src=" imgs/space.png"><img id="ste_3" src=" imgs/star_grey.png" alt="" onclick="highlight_star_fix3(this.id);" onmouseover="this.style.cursor=\'pointer\'; highlight_star3(this.id);" onmouseout="reset_fixed3();"><img src=" imgs/space.png"><img id="ste_4" src=" imgs/star_grey.png" alt="" onclick="highlight_star_fix3(this.id);" onmouseover="this.style.cursor=\'pointer\'; highlight_star3(this.id);" onmouseout="reset_fixed3();"><img src=" imgs/space.png"><img id="ste_5" src=" imgs/star_grey.png" alt="" onclick="highlight_star_fix3(this.id);" onmouseover="this.style.cursor=\'pointer\'; highlight_star3(this.id);" onmouseout="reset_fixed3();"></td><td id="b3" style="color:#000000;font-size:15px; font-family:arial; font-weight:bolder;"></td><td><img src=" imgs/infob.png"></td></tr><tr><td id="option">Gesamtempfehlung</td><td><img id="st_1" src=" imgs/star_grey.png" alt="" onclick="highlight_star_fix4(this.id);" onmouseover="this.style.cursor=\'pointer\'; highlight_star4(this.id);" onmouseout="reset_fixed4();"><img src=" imgs/space.png"><img id="st_2" src=" imgs/star_grey.png" alt="" onclick="highlight_star_fix4(this.id);" onmouseover="this.style.cursor=\'pointer\'; highlight_star4(this.id); " onmouseout="reset_fixed4();"><img src=" imgs/space.png"><img id="st_3" src=" imgs/star_grey.png" alt="" onclick="highlight_star_fix4(this.id);" onmouseover="this.style.cursor=\'pointer\'; highlight_star4(this.id);" onmouseout="reset_fixed4();"><img src=" imgs/space.png"><img id="st_4" src=" imgs/star_grey.png" alt="" onclick="highlight_star_fix4(this.id);" onmouseover="this.style.cursor=\'pointer\'; highlight_star4(this.id);" onmouseout="reset_fixed4();"><img src=" imgs/space.png"><img id="st_5" src=" imgs/star_grey.png" alt="" onclick="highlight_star_fix4(this.id);" onmouseover="this.style.cursor=\'pointer\'; highlight_star4(this.id);" onmouseout="reset_fixed4();"></td><td id="b4" style="color:#000000;font-size:15px; font-family:arial; font-weight:bolder;"></td><td id="vote"><img src=" imgs/votebg.png"></td></tr></table><input id="rating1" type="hidden" name="rating1" value="0"><input id="rating2" type="hidden" name="rating2" value="0"><input id="rating3" type="hidden" name="rating3" value="0"><input id="rating4" type="hidden" name="rating4" value="0"><input type="hidden" name="k" value="kingsend"></form>';
}
}
else{
document.getElementById("voterahmen").innerHTML = '<table height="163" width="595"><tr><td id="option">Für das Voting müssen die Cookies in deinem Browser aktiviert sein! <a href="http://www.google.de/support/websearch/bin/answer.py?hl=de&answer=35851" style="color:black;" onclick="oeffnen();">Hilfe</a></td></tr></table>';
}
}
PHP-Code:
function setzeboxcookie(){
var a = new Date();
a = new Date(a.getTime() + 1000*60*60*24);
document.cookie = 'box=kingsend; expires='+ a.toGMTString()+';';
Kommentar