Page 1 of 1
need codes to set cookies
Posted: Wed Nov 24, 2004 5:18 pm
by sean82
hi
i look for a script that makes a link on an introducing page and by clicking the link cookies are set for this user and when he visits this page again he will be redirected to other url,
so he doesnt need always to visit this page
thx for help
Posted: Wed Nov 24, 2004 5:24 pm
by Archy
You will need to set a cookie:
Code: Select all
setcookie('cookie_name', 'Cookie value', time()+86400);
Think this is a day in time.
Then just make a redirection script thing:
Code: Select all
<?PHP
ob_start();
if($_GET['$Cookie_name'] != ""){
header("Location: URL.com"); exit();
}
...
...
?>
Tha should be a start.
Posted: Wed Nov 24, 2004 6:31 pm
by sean82
hi
thx i tried this but unfortunately it doesnt work
Code: Select all
<?
setcookie('nomoremovie', 'Cookie value', time()+86400);
?>
<?PHP
ob_start();
if($_GET['$nomoremovie'] != ""){
header("Location: http://www.mysite.com/index.php?crash=start");exit();
}
...
...
?>
the setcookie was on the very 1 line
Posted: Wed Nov 24, 2004 6:57 pm
by rehfeld
Code: Select all
<?php
$cookie_expire = time() + 86400; // 1 day
if (isSet($_GET['please_set_my_cookie'])) {
setcookie('nomoremovie', 'true', $cookie_expire);
header("Location: http://www.mysite.com/index.php?crash=start");
exit;
}
if (isSet($_COOKIE['nomoremovie'])) {
header("Location: http://www.mysite.com/index.php?crash=start");
exit;
}
?>
then make a link which directs to this script like
<a href="script.php?please_set_my_cookie">remember me</a>
is that what you mean?
Posted: Thu Nov 25, 2004 1:13 am
by sean82
exactly what i need but it gives this error
Warning: Cannot modify header information - headers already sent by (output started at /home/www/web../html/nomoremovie.php:2) in /home/www/web../html/nomoremovie.php on line 5
i made the codes in a nomoremovie.php file and a link this way
<a href="nomoremovie.php?please_set_my_cookie">remember me</a>
Posted: Thu Nov 25, 2004 1:17 am
by nigma