Topic: JavaScript Cookie Redirect (Page 1 of 1) |
|
|---|---|
|
Obsessive-Compulsive (I) Inmate From: |
posted 04-19-2008 07:27
Hello everybody. I just joined this forum today and I must say I'm glad I did, helped me in making a cookie redirect script. I though to share this one because believe me I've searched everywhere... no skills = no power I suppose code: <script language="JavaScript">
function setCookie(name, value, expires)
{
if (!expires) expires = new Date();
document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() + "; path=/";
}
var expdate = new Date ();
expdate.setTime(expdate.getTime() + 999999999);
setCookie("NameOFtheCOOKIE","true",expdate);
</script>
code: <script>
<!--
go_to = "http://www.site.com/pageC.html";
function readCookie(cookieName){
var start = document.cookie.indexOf(cookieName);
if (start == -1){
document.cookie = "NameOFtheCOOKIE" + ged(num_days);
} else {
window.location = go_to;
}
}
readCookie("NameOFtheCOOKIE");
// -->
</script>
code: <script>
<!--
go_to = "http://www.site.com";
num_days = 60;
function ged(noDays){
var today = new Date();
var expr = new Date(today.getTime() + noDays*24*60*60*1000);
return expr.toGMTString();
}
function readCookie(cookieName){
var start = document.cookie.indexOf(cookieName);
if (start == -1){
document.cookie = "seenit=yes; expires=" + ged(num_days);
} else {
window.location = go_to;
}
}
readCookie("seenit");
// -->
</script>
|
|
Paranoid (IV) Mad Librarian From: ber/ger |
posted 04-21-2008 21:42
Hello cyanide, welcome to the funny farm code: num_days = 60;
function ged(noDays){
var today = new Date();
var expr = new Date(today.getTime() + noDays*24*60*60*1000);
return expr.toGMTString();
}
|
|
Nervous Wreck (II) Inmate From: |
posted 04-22-2008 01:26
Hi kuckus, thank you for your help. code: <script>
<!--
num_days = 5;
function ged(noDays){
var today = new Date();
var expr = new Date(today.getTime() + noDays*24*60*60*1000);
return expr.toGMTString();
}
go_to = "index2.php";
num_days = 5;
function readCookie(cookieName){
var start = document.cookie.indexOf(cookieName);
if (start == -1){
document.cookie = "bin" + ged(num_days);
} else {
window.location = go_to;
}
}
readCookie("bin");
// -->
</script>
code: <script language="JavaScript">
function setCookie(name, value, expires)
{
if (!expires) expires = new Date();
document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() + "; path=/";
}
var expdate = new Date ();
expdate.setTime(expdate.getTime() + 999999999);
setCookie("<?php echo $sold;?>","true",expdate);
</script>
<script>
code: $sold = "no";
code: <script>
<!--
go_to = "index3.php";
num_days = 5;
function readCookie(cookieName){
var start = document.cookie.indexOf(cookieName);
if (start == -1){
document.cookie = "yes" + ged(num_days);
} else {
window.location = go_to;
}
}
readCookie("yes");
// -->
</script>
|
|
Nervous Wreck (II) Inmate From: |
posted 04-26-2008 06:34
Any ideas on the request i made ? I admit i'm a complete and utterly dumb ass when it comes to php/javascript coding! |