| |||||||
Du magst keine Werbung? Wir auch nicht!
Einfach registrieren und die Werbung ist weg. Diese Nachricht sehen nur nicht registrierte Nutzer.
![]() |
| | LinkBack | Themen-Optionen | Ansicht |
| | #1 (permalink) |
| Neuer User Registriert seit: Jul 2005
Beiträge: 6
| Help Me With Cookies, HTML and IE8
Help Me With Cookies, HTML and IE8 For complex reasons, I have to use HTML with JavaScript to set a cookie. I know it is easy to set and get cookies PHP but I have to put the code in HTML. I have searched the internet for some examples and I ran a test based on an example. I ran this Javascript code: Code: <SCRIPT LANGUAGE="JavaScript">
function putCookie()
{
cookie_name = "specialcookiehuge";
if(document.cookie != document.cookie)
{
index = document.cookie.indexOf(cookie_name);
}
else
{
index = -1;
}
if (index == -1)
{
document.cookie=cookie_name+"; expires=Monday, 04-Apr-2020 05:00:00 GMT";
}
}
</SCRIPT> Code: document.cookie=cookie_name+"; expires=Monday, 04-Apr-2020 05:00:00 GMT"; I tried to find this cookie (Tools -> Internet Options -> Browsing History ->Settings) And I did not find anything named "specialcookiehuge" in "View Objects" or "View Files". I guess I could try other browsers, but it would be good to know what I am doing wrong. I do not know if I am really setting a cookie. Is there some additional javascript command I am missing? Or, is the cookie being set but I am not looking in the right place according to the tutorials I saw online? |
| | |
| | #2 (permalink) |
| Inventar Registriert seit: Jul 2002
Beiträge: 6.979
|
The Code is correct but probably you are using a date to far in future. Try this: Code: <script type="text/javascript">
function putCookie()
{
cookie_name = "specialcookiehuge";
if(document.cookie != document.cookie)
{
index = document.cookie.indexOf(cookie_name);
}
else
{
index = -1;
}
if (index == -1)
{
var d = new Date();
var d2 = d.getTime() + ( 5 * 24 * 60 * 60 * 1000 );
d.setTime( d2 );
document.cookie=cookie_name+"; expires=" + d.toGMTString();
}
}
putCookie();
</script>
__________________ (\__/) (='.'=) (")_(") Geändert von Nightflyer (14-02-2011 um 06:16 Uhr) |
| | |
| | #3 (permalink) |
| Neuer User Registriert seit: Jul 2005
Beiträge: 6
|
Thanks for your suggestion. I tried your suggested modifications but I did not see any cookie generated. I think I know where IE8 stores cookies: C:\Users\...\AppData\Local\Microsoft\Windows\Tempo rary Internet Files and I did not see a new cookie there. I tried Safari: C:\Users\...\AppData\Roaming\Apple Computer\Safari\Cookies and I did not see a new cooke there either. |
| | |
![]() |
| Lesezeichen |
| Themen-Optionen | |
| Ansicht | |
| |
Ähnliche Themen | ||||
| Thema | Autor | Forum | Antworten | Letzter Beitrag |
| Mit Cookies auf HTML-Unterseiten an bestimmte Stellen im Flashfilm springen? | schmitt197 | Flash 4 und Flash 5 | 0 | 28-04-2004 14:06 |
| Cookies? | Nightflyer | PHP und MySQL | 7 | 11-10-2003 20:16 |
| Cookies | dreck | Flash und Datenbanken | 2 | 08-01-2003 22:23 |
| Cookies | ronald | Flash 4 und Flash 5 | 1 | 10-12-2001 08:40 |
| cookies, wie? | Gargoyle | HTML und CSS | 5 | 21-08-2001 11:13 |