| | | | |
| |||||||
| JavaScript, Ajax und mehr dynamisches Scripten und Interaktion auf Clientebene |
|
| | LinkBack | Themen-Optionen | Thema bewerten |
| | |
| PHP Code Flüsterer Registriert seit: 21.08.2005 Beiträge: 4682 PHP-Kenntnisse: Fortgeschritten | |
| | |
| Erfahrener Benutzer | Hast du die Augen zu gehabt als du bei Google "Javascript Cookies" eingegeben hast ?
__________________ |
| | |
| | |
| Moderator¹ Registriert seit: 28.03.2010
Beiträge: 7.470
PHP-Kenntnisse: Fortgeschritten ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Der Code ist ja auch Murks. Zum Cookie-Handling in JavaScript gibt's aber genügend fertiges. Und bei SELFHTML kannst du auch nachlesen, wie man mit dem Inhalt von document.cookie umgeht.
__________________ RGB is totally confusing - I mean, at least #C0FFEE should be brown, right? |
| | |
| | |
| Moderator Registriert seit: 11.05.2008
Beiträge: 6.266
![]() ![]() ![]() ![]() ![]() ![]() ![]() | Schau dir dieses Skript mal an, entweder mit Chrome oder mit Firefox und Firebug-Plugin. Dann Konsole aufmachen und ausführen: Code: // Cookies zu Testzwecken anlegen:
document.cookie = "test123=wert123";
document.cookie = "test456=wert456";
document.cookie = "test789=wert789";
console.log("document.cookie: ", document.cookie);
// "test123=wert123; test456=wert456; test789=wert789"
var cookiesRaw = document.cookie.split(";");
console.log("cookiesRaw: ", cookiesRaw);
// ["test123=wert123", " test456=wert456", " test789=wert789"]
var cookies = {};
for (var name, value, i = 0, x = cookiesRaw.length; i < x; ++i) {
name = cookiesRaw[i].split("=")[0].replace(/^\s+/, ""); // mit ltrim(), test123
value = cookiesRaw[i].split("=")[1]; // wert123
cookies[name] = value;
}
console.log("cookies: ", cookies);
// { test123: "wert123", test456: "wert456", test789: "wert789" }
if (typeof cookies["test123"] != "string") {
console.log("Kein Treffer für test123");
} else {
console.log("Treffer test123: ", cookies["test123"]);
}
if (typeof cookies["xyz123"] != "string") {
console.log("Kein Treffer für xyz123");
} else {
console.log("Treffer xyz123: ", cookies["xyz123"]);
}
__________________ "Nuschel ich?" - "Was?" |
| | |
|
| Themen-Optionen | |
| Thema bewerten | |
|
|
Ähnliche Themen | ||||
| Thema | Autor | Forum | Antworten | Letzter Beitrag |
| Website setzt kein Cookie unter Curl | ragro | PHP Einsteiger | 4 | 03.04.2011 20:07 |
| Cookie setzen und auslesen | Rutor | PHP Einsteiger | 8 | 28.01.2011 08:55 |
| [Erledigt] Kein cookie mit setcookie | SteiniKeule | PHP Tipps 2010 | 5 | 10.05.2010 17:37 |
| [Erledigt] sessions und cookie | melody | PHP Tipps 2010 | 6 | 03.04.2010 15:11 |
| [Erledigt] Datei existiert, Zähler mit Schleife | FloRic | PHP Tipps 2009 | 2 | 12.01.2010 20:54 |
| Javascript Cookie Problem | scheffie | JavaScript, Ajax und mehr | 14 | 19.07.2009 05:07 |
| iPhone - Cookie verfällt nicht | Maaax | PHP Tipps 2009 | 5 | 02.07.2009 10:29 |
| Cookie löschen funktioniert nicht | GSJLink | PHP Tipps 2007 | 2 | 24.01.2007 14:55 |
| Prüfung ob eine Session schon existiert | Mano | PHP Tipps 2006 | 14 | 18.08.2006 19:40 |
| [Erledigt] Autologin mit Cookie, wie? Beste Lösung? | PHP-Fortgeschrittene | 17 | 16.02.2006 14:03 | |
| Cookie setzten funktioniert nicht!? | nicobischof | PHP Tipps 2006 | 13 | 06.01.2006 13:38 |
| Cookie | DER_Brain | PHP Tipps 2005-2 | 4 | 27.06.2005 17:49 |
| Cookie löschen | tomtaz | PHP Tipps 2005-2 | 3 | 06.06.2005 20:50 |
| [Erledigt] Cookie - Seite anzeigen / nicht anzeigen | PHP Tipps 2004-2 | 2 | 11.11.2004 15:59 | |
| Cookie / localhost / Problem gelöst | PHP-Fortgeschrittene | 11 | 02.11.2004 22:41 | |
| Besucher kamen über folgende Suchanfragen bei Google auf diese Seite |
| javascript cookie existiert, javascript prüfen ob cookie vorhanden, javascript prüfen ob cookie existiert, javascript prüfen ob cookie gesetzt, php cookie überprüfung 2011, testen ob cookie existiert php, php überprüfen ob cookie vorhanden, php prüfen ob cookie vorhanden, prüfen ob cookie vorhanden php, javascript cookie vorhanden überprüfen, prüfen, ob cookie vorhanden ist php, prüfen ob cookies aktiviert sind, prüfen ob cookie vorhanden, prüfen ob cookie existiert javascript, prüfen ob cookie name vorhanden, php ob cookie vorhganden, javascript cookie handling, php prüfen ob cookie existiert, javascript cookie prüfung, php prüfen ob cookie exestiert |