View Full Version : Conceptualize: use php cookie to track user
Flash Gordon
11-13-2005, 06:22 PM
This has kind of been talked about before in the flash side, but I need a bit of help NOT doing it in flash just html/php.
I need a concept of how to track a user through my site. Here is the info I would like to know:
1) How many times have they visited previously?
2) What is the order of links or what links they clicked?
3) Referer?
My problems is not the coding (at least i don't think) but just how to set it up efficiently. I'm guessing mysql database is where it will all get stored.
Does anyone know a tutorial for this? Will this kind of cookie get labeled as "tracking" by AdWare abd be blocked?
Thanks for the time and help.
FG
DB :
ID --- USER --- StartTime --- RequestTime --- Link
USER --> Get it from the cookie
Link --> the requested link
RequestTime -->curent Time
StartTime -->
you check the highest (newest) "RequestTime" from the USER
if it's longer ago then X minutes then it's a new visit
we Write The curent Time to StartTime else Way the newes (highest) StartTime
info you get
how many time he was there
when what link
whow long per visit
...
..
.
whit the proper search rules you will know what sox the guy was wearing :p
Hup referer
Hmmm
one more (i simply can't hold this 2 separate so either NEW COL OR New ROW wich ever the corect one)
Referer
P.S
AdWare -->
it's nothing else then the login cookie from here (as.org)
all of the AdWare scaner have signatures of the cookie and or now from wich side they are
so as long your side isn't on the black list of the scaner it won't recognize the cookie as a tracking one
and they will block it as fare they woud block the login cookie from here
you can make a sesioncookie and check have they or not accept the cookie in this case you write the IP to the USER
Flash Gordon
11-13-2005, 07:19 PM
Thank you.
One more question and then I will give it a shot:
Each new link the user links on will create a new row in the database consisiting of ID --- USER --- StartTime --- RequestTime --- Link. Is that correct?
Or should they get grouped together by USER somehow?
Thanks Xeef.
BTW, Antechinus doesn't auto format like I thought. That function only finds the beginning and ends of braces "{ }"
my SQL is at noob level :p
not realy know how to grup them tugether and even if
so you have one DB (Hmmm coud by realy big :) ) so you can make realy nice searches
like what sides was visited betwean 16:00 and 20:00 on each first monday of a months
wich side was wisited the most on the 5 click
on wich side was the avrage user the longest time
how often are users per day on your side
...
endless posobilitis
Hmmmm
as the DB coud get realy big it woud mayby by an idea to split it Monthly
or even weekly if you have 100000 clicks a day :p
Flash Gordon
11-13-2005, 09:38 PM
Okay, I'm working on it. It turns out, this has less to do with cookies and more with databases. Right now, I stuck 1 thing (2 part): it is the startTime / visitNumber. Here is my current php. It is VERY beta, but I'm just trying to get all the info I want to input first.
<?php
if(!isset($_COOKIE['visitor'])) {
session_start();
$user = session_id();
$ok = setcookie('visitor', $user, time()+3600*24*30);
if($ok) {
echo "success";
}
} else {
echo "cookie already set: " . $_COOKIE['visitor'];
}
$ip = $_SERVER['REMOTE_ADDR'];
$page = $_SERVER['PHP_SELF'];
$referer = $_SERVER['HTTP_REFERER'];
$startTime = "";
$requestTime = time();
//$visitNumber will be termed in sql.
?>
Right now, I'm fuzzy on how to get the startTime and how to get visitNumber. For instance visitNumber 10 could have 13 hits, then they come back for visitNumber 11 two days later and have 17 hits, etc. How do I need to script that?
Other questions:
1) Is the way I set the $user okay?
2) Is the way I set $requestTime okay?
Thanks.
you check the DB on each request
psoido code it's long ago i did something whit SQL
WHERE USER=$_COOKIE['user'] AND (MAX requestTime)
this shoud give the last Access
you check the requestTime on this
if it's ages ago then you write as startTime the CURENTTime
else way the Starttime this request gived
(if the user isn't in the DB then as it woud by ages ago since the last access)
DB woud look like :
S 10-00 E:10-00 U:Xeef P:index
S 10-00 E:10-03 U:Xeef P:Bla
S 10-00 E:10-07 U:Xeef P:Bla/Image
S 10-00 E:10-15 U:Xeef P:index
//here i logof (go some where else)
//now i am back agein --> this is the last data (S 10-00 E:10-15 U:Xeef P:index)
//we have 18-00 we compare this to E:10-15 this are a couple of hours later
//nobody will view a side such long
//we set a new StartTime
S 18-00 E:18-00 U:Xeef P:index
S 18-00 E:18-08 U:Xeef P:GuestBook
S 18-00 E:18-10 U:Xeef P:Game
logof again
S 21-15 E:21-15 U:Xeef P:index
S 21-15 E:21-20 U:Xeef P:index
S 21-15 E:21-40 U:Xeef P:index
to get the number of visits you need to search for the amount of unique StartTime by the same user
total hits the numer of entris whit the user
Flash Gordon
11-13-2005, 10:31 PM
here is something I came up with before I read your post:
$startTime = "";
$requestTime = time();
setcookie("lastRequest", $requestTime, time()+3600*24*30);
if($requestTime - $_COOKIE['lastRequest'] > 20) {
echo "<br> new visit <br>";
echo $requestTime - $_COOKIE['lastRequest'];
} else {
echo "same visit";
echo $requestTime - $_COOKIE['lastRequest'];
}
Now let me go back and read what you, graciously, wrote.
Flash Gordon
11-13-2005, 11:59 PM
current code:
<?php
//------------------------track user's navigation and stats.
// -------- set cookie is not already set
if(!isset($_COOKIE['visitor'])) {
session_start();
$user = session_id();
$ok = setcookie('visitor', $user, time()+3600*24*30);
$firstVisit = "true";
if($ok) {
//echo "success";
}
} else { //cookie already set
$user = $_COOKIE['visitor'];
$firstVisit = "false";
}
// ------- get values I want to record to database
//$user defined above
$ip = $_SERVER['REMOTE_ADDR'];
$page = $_SERVER['PHP_SELF'];
$referer = $_SERVER['HTTP_REFERER'];
$startTime = "";//set below
$requestTime = time();
//$newVisit is set below.
//$firstVisit is recorded above
setcookie("lastRequest", $requestTime, time()+3600*24*30);
if(isset($_COOKIE['lastRequest'])) {
if($requestTime - $_COOKIE['lastRequest'] > 60*30) {
$newVisit = "true";
$startTime = time();
} else {
$newVisit = "false";
}
$timeElapse = $requestTime - $_COOKIE['lastRequest'];
} else {
$newVisit = "true";
$timeElapse = "";
}
//$information = array('user' => $user, 'ip' => $ip, 'page' => $page, 'referer' => $referer, 'startTime' => $startTime, 'requestTime' => $requestTime, 'newVisit' => $newVisit, 'firstVisit' => $firstVisit, 'timeElapse' => $timeElapse);
//print_r($information);
//--------------insert info into database
$myDatabase = "*******";
$myTable = date("F");
$myUser = "*******";
$myPassword = "******";
//-----connect to database
mysql_connect(localhost,$myUser,$myPassword) or die("Could not connect");
mysql_select_db($myDatabase) or die ("Could not select the database");
//-----insert into database
$query = "INSERT INTO " . $myTable . " VALUES('', '$user', '$ip', '$page', '$referer', '$startTime', '$requestTime', '$newVisit', '$firstVisit', '$timeElapse')";
mysql_query($query);
?>
Since I am a noob using mySQL :D what needs to be the "correct" structure of my database?
Here is my current layout:
ID: INT(11)
user: varchar(255)
ip: varchar(255)
page: text
referer: text
startTime: text
requestTime: text
newVisit: varchar(5)
firstVisit: varchar(5)
timeElapse: int(255)
I know that has to be some "type mismatches".
Also, can anyone think of some other really cool stuff to log as well, in addition to their socks color? :D
you use the session id as the user name if i am not wrong it is 32 long
why also 255 ?
same whit IP
newVisit: varchar(5)
firstVisit: varchar(5)
timeElapse: int(255)
you not realy need them can by callculated from the other data
Flash Gordon
11-14-2005, 03:50 AM
Hey Xeef,
Ever seen thoses little signiture where they say your "IP", "ISP", "Operating System", and "Browser"?
Do you know the php script for someones operating system? I figured it would be a super-global / pre-defined variable but I can't find it.
How about the ISP? I assume that is a webservice?
Oh yeah.....THANKS for all the help.
Also, I plan to embed a small flash file to record the screen resolution, and flash player version, in addition to the one above.
CyanBlue
11-14-2005, 05:48 AM
This script...
<?php
echo($_SERVER['HTTP_USER_AGENT']);
?>
displays this...
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.40607)
Why do you need the ISP??? If you have problem, use the IP address and it should help you track down where the user is and who the service provider is... ;)
Flash Gordon
11-14-2005, 06:10 AM
Your right I don't, actually I'm kind of just having fun :D
I got some really cool stuff by doing this in flash:
var LV:LoadVars = new LoadVars();
LV.os = System.capabilities.os;
LV.flashPlayer = System.capabilities.version;
LV.resolution = System.capabilities.screenResolutionX+" x "+System.capabilities.screenResolutionY;
LV.sendAndLoad("session.php", LV, "POST");
However, I lose the referrer. It would be great if I could have both worlds.
Any ideas?
CyanBlue
11-14-2005, 06:44 AM
I have no idea what you are doing with that code cuz I am just too lazy to go over the whole thread, but look up the HTTP_REFERER and that should be the one that you are looking for... ;)
Flash Gordon
11-14-2005, 06:56 AM
yeah, thanks! I got that happening.
For me to get the operating system, flash player, and screen resolution of the user, I embed a tiny swf in the file and used sendAndLoad to call my php file which write to the database. However, when I do this I lose the referrer since Flash is calling the file and not getting linked to anymore.
It's a toss up right now. I hope I can find a solution that will let me get both os and referrer.
THANKS AGAIN!
but you shoud get the referer when they call the side whit the flash movie !?
1.
call your side
2.
record referer make a session
send the side whit the embeded flash
3.
flash sends the info
4.
record the aditional info to the proper place or to the next row
row 1 -- S:10-00 Ref:www.as.org Plug:Session Start not detected
row 2 -- S:10-01 Ref:Self (here you lose the referer or you self are it) Plug :F8.5 .....
5. There are ways to detect the plug in whit JS (i think it's a bit stressi to make it crossbrowser) there shoud by also ways to detect the rest of the info whit JS whit out the need of Flash
Flash Gordon
11-15-2005, 04:18 PM
but you shoud get the referer when they call the side whit the flash movie !?
Got ya. Have the swf embeded in a PHP page, send the referrer to flash, and then send all statistics at once to the database
mySWF.swf?reffer=$_SERVER['code']
Hmmmm
nice idea to send it to flash ;)
CyanBlue
11-15-2005, 05:30 PM
I thought that Xeef's #2 meant exactly that... :)
no i was meant to save the referer straight on the SWF request to the DB
and later either look up the id in the DB and write the aditional info from flash to it or just create a NEW entry whit this info
this is the frist request :
row 1 -- S:10-00 Ref:www.as.org Plug:Session Start not detected
what flash sends
row 2 -- S:10-01 Ref:Self (here you lose the referer or you self are it) Plug :F8.5 .....
whit FG's methode you have one entry less BUT incase the user is canseling the side (takes to long to lad the SWF) you have NO entry atall ;) and i think this is an important info because it's inficate your preloader sucks or isn't nice enougth
Flash Gordon
11-15-2005, 06:11 PM
Can anyone explained what happened here:
user ip page referer startTime requestTime firstVisit newVisit timeElapse
3632d8ff5d811d48d2cb262a6f43f392 203.22.204.xxx /index2.php "BLANK" 1132035407 1132035407 true true 0
1c19e9f9aceb436bbcacc7fb1c989270 203.22.204.xxx /index2.php "BLANK" 1132037515 1132037515 true true 0
You can see that the IP addresses are the same, however the USER (or session_id) doesn't really every stick with that user. And each page they click gets logged as a new visitior and visit. Also, the referrer straight from $_SERVER['HTTP_REFERER']; is blank
Any ideas why the cookie doesn't stick and the referrer is "" ?
(Perhaps I should have used more butter :D )
Flash Gordon
11-15-2005, 06:59 PM
The weird thing is, it is like that on only a couple of user's. Most log just fine. I kind of figured the user's securtity settings mights have been high or he might have used a proxy that hide the referrer
Code:
<?php
//------------------------track user's navigation and stats.
// -------- set cookie is not already set
if(!isset($_COOKIE['visitor'])) {
session_start();
$user = session_id();
$ok = setcookie('visitor', $user, time()+3600*24*30);
$firstVisit = "true";
if($ok) {
//echo "success";
}
} else { //cookie already set
$user = $_COOKIE['visitor'];
$firstVisit = "false";
}
// ------- get values I want to record to database
//$user defined above
$ip = $_SERVER['REMOTE_ADDR'];
$page = $_SERVER['PHP_SELF'];
$referer = $_SERVER['HTTP_REFERER'];
// $startTime = set below
$requestTime = time();
//$newVisit is set below.
//$firstVisit is recorded above
setcookie("lastRequest", $requestTime, time()+3600*24*365);
if(isset($_COOKIE['lastRequest'])) {
if($requestTime - $_COOKIE['lastRequest'] > 60*30) {
$newVisit = "true";
$startTime = time();
} else {
$newVisit = "false";
$startTime = "same visit";
}
$timeElapse = $requestTime - $_COOKIE['lastRequest'];
} else {
$newVisit = "true";
$timeElapse = "";
$startTime = time();
}
/*
$os = $_POST['os'];
$flashPlayer = $_POST['flashPlayer'];
$resolution = $_POST['resolution'];
echo $os . " " . $resolution ." " . $flashVersion;
*/
//$information = array('user' => $user, 'ip' => $ip, 'page' => $page, 'referer' => $referer, 'startTime' => $startTime, 'requestTime' => $requestTime, 'newVisit' => $newVisit, 'firstVisit' => $firstVisit, 'timeElapse' => $timeElapse);
//print_r($information);
//--------------insert info into database
$myDatabase = "*****";
$myTable = date("F");
$myUser = "****";
$myPassword = "******";
//-----connect to database
mysql_connect(localhost,$myUser,$myPassword) or die("Could not connect");
mysql_select_db($myDatabase) or die ("Could not select the database");
//-----insert into database
$query = "INSERT INTO " . $myTable . " VALUES('', '$user', '$ip', '$page', '$referer', '$startTime', '$requestTime', '$firstVisit', '$newVisit', '$timeElapse')";
mysql_query($query);
?>
'HTTP_REFERER'
The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
eg if i open an epty browser and type your side in --> NO referer !
if i set it as my homeside there shoud by also no referer
i don't accept any cookies at all ALSO no session cookie !
there is some PHP/apache directive wich automaricly replace any
www.Bla.com
whit
www.Bla.com?SID=1c19e9f9aceb436bbcacc7fb1c989270
if session cookies aren't alowed
Hmmmmmm
not sure coud by this !?
session.use_trans_sid boolean
session.use_trans_sid whether transparent sid support is enabled or not. Defaults to 0 (disabled).
Note: For PHP 4.1.2 or less, it is enabled by compiling with --enable-trans-sid. From PHP 4.2.0, trans-sid feature is always compiled.
URL based session management has additional security risks compared to cookie based session management. Users may send an URL that contains an active session ID to their friends by email or users may save an URL that contains a session ID to their bookmarks and access your site with the same session ID always, for example.
so basicly what i was making (long time ago)
1. www.Bla.com/index.php
user request side --> side try to write session cookie
2. www.Bla.com/index.php?Init=true
load the side agein check the cookie if there is NO cookie user didn't alowe session cookis
3. switch to server side cookies ini_set("session.use_cookies",0);
whit ini_set(session.use_trans_sid,1) (as i sad not absolutly sure that this is the syntax)
4. any future side will by served in this form : href="www.abc.com/side?SID=3632d8ff5d811d48d2cb262a6f43f392"
you not have to care for anything else the session id is automaticli gathered from this
of course if Flash comes in to the game aditional action is required
because this will not work "href="www.abc.com/side?SID=3632d8ff5d811d48d2cb262a6f43f392"" PHP will not analize your SWF and recompile it :p
Flash Gordon
11-15-2005, 08:20 PM
1. www.Bla.com/index.php
user request side --> side try to write session cookie
2. www.Bla.com/index.php?Init=true
load the side agein check the cookie if there is NO cookie user didn't alowe session cookis
3. switch to server side cookies ini_set("session.use_cookies",0);
whit ini_set(session.use_trans_sid,1) (as i sad not absolutly sure that this is the syntax)
4. any future side will by served in this form : href="www.abc.com/side?SID=3632d8ff5d811d48d2cb262a6f43f392"
you not have to care for anything else the session id is automaticli gathered from this
I think I understand what you mean there. I will have to tweek my coding a bit.
Flash Gordon
11-15-2005, 11:36 PM
I thought that this would work:
$ok = setcookie("test", "hello world");
However it doesn't:
If output exists prior to calling this function, setcookie() will fail and return FALSE. If setcookie() successfully runs, it will return TRUE. This does not indicate whether the user accepted the cookie.
Are you suggesting that I try to set the cookie and then refresh the page and check if the cookie is set? Something like this:
<?php
setcookie("test", "this is a test", time()*60*60);
header("Location: " . $_SERVER['PHP_SELF']); //endless loop. DUH!
if(isset($_COOKIE['test'])) {
//do my above coding
} else {
//not to sure yet :(
}
?>
like :
if (isset($_GET["BLA"])){
if (isset($_COOKIE['visitor'])){"all OK"}else{Cookie not accepted}
}else{
setcookie('visitor', $user, time()+3600*24*30);
}
this coud by also made by 2 files
eg.
index.php -->just write the cookie and load MainIndex.php
if you have No cookie in MainIndex.php then index.php wasn't abel to set it
aditional tasks are needed
Flash Gordon
11-16-2005, 03:10 AM
kind of a side note:
A- Users double click on links or make 2 clicks very fast. The same key is sent for the 2 clicks because the new key from the first click didn't get to the browser on time for the second one but the session on the server did trash the key for the new one. Thus, the second click causes a termination of the session. (install the LiveHttpHeaders extension on firefox and look at the headers sent when you click twice very fast, you'll see the same cookie sent on both and the new cookie getting back from the server too late).
B- For any given reason, the server experiences a slow down and the response with the new key (which has replaced the old one on the server) is not returned to the browser fast enough. The user gets tired of waiting and clicks somewhere else. He gets logged out because this second click send the old key which won't match the one you have on your server.
That could have account for the double session ID for one user.
A- Users double click on links or make 2 clicks very fast. The same key is sent for the 2 clicks because the new key from the first click didn't get to the browser on time for the second one but the session on the server did trash the key for the new one
B- For any given reason, the server experiences a slow down and the response with the new key (which has replaced the old one on the server) is not returned to the browser fast enough. The user gets tired of waiting and clicks somewhere else. He gets logged out because this second click send the old key which won't match the one you have on your server.
Heeeee ??
normaly you have ONE key during the hole session !
wich never change !
this text makes no sens to me at all :p
i mean you have the ability in PHP to generate a NEW Session key by WILL
but you don't do that ?
so abouth what 2. key are they talking ???????
Hmmmm
if you have a link wich opens a New browser window
wich links to your side and somebody start to click like an idiot on it
then he will have a lot of open "your" sides whit each an unique session key
but this shoud by also the case if i surf a round on your side and open a "FRESH" browser and type your side in
here you even can gain more info abouth the users behave
if you have a referer and 2 diferent session tath means the referer is linking whit a NEW browser window to your side and the user has click it more times
(unless he had this side open more times and clicked in all instances on the link wich is also posible but unlikely in this case the referer isn't opening a new browser for the link "_self" )
if you have no referer but a lot of diferent sessions
like :
S: 10-00 .... P:index.php ID :hjker9804322
S: 10-00 .... P:index.php ID :erw90434343
S: 10-00 .... P:index.php ID :3434kljdsfdfd
S: 10-00 .... P:index.php ID :34jkljrew343
S: 10-00 .... P:index.php Id : jkljer083094
S: 10-01 .... P:images.php?P=1 ID :3434kljdsfdfd
S: 10-01 .... P:images.php?P=2 ID :3434kljdsfdfd
S: 10-01 .... P:images.php?P=3 ID :3434kljdsfdfd
....
so there are lot of sessions but just ONE is in real use
this woud mean to me the user has set your side as homepage
and has just started to surf around has opened X browser instances
using the Xth instance to stay on your side
and the other browsers for something else
Flash Gordon
11-16-2005, 05:00 PM
Heeeee ??
normaly you have ONE key during the hole session !
wich never change !
this text makes no sens to me at all :p
i mean you have the ability in PHP to generate a NEW Session key by WILL
but you don't do that ?
so abouth what 2. key are they talking ???????
I got that from the user's comments in the php manuel (online) under the cookies section. Yeah, your right, it wouldn't generate another key.
Flash Gordon
11-16-2005, 05:50 PM
URGH!
Am I miss understaning the path parameter of setcookie()? My code (shown below) puts a cookie with the path of each folder, although I am trying to tell it to put it in the root directory. Is my coding wrong?
<?php
//------------------------track user's navigation and stats.
// -------- set cookie is not already set
if(!isset($_COOKIE['visitor'])) {
session_start();
$user = session_id();
setcookie('visitor', $user, time()+3600*24*365, "/");
$firstVisit = "true";
} else { //cookie already set
$user = $_COOKIE['visitor'];
$firstVisit = "false";
}
// ------- get values I want to record to database
//$user defined above
$ip = $_SERVER['REMOTE_ADDR'];
$page = $_POST['page'];
$referer = "";
$requestTime = date('h:i:s A');
$dayOfWeek = date('l');
$browser = $_SERVER['HTTP_USER_AGENT'];
// $startTime = set below
//$newVisit is set below.
//$firstVisit is recorded above
setcookie("lastRequest", time(), time()+3600*24*365, "/");
if(isset($_COOKIE['lastRequest'])) {
if(time() - $_COOKIE['lastRequest'] > 60*30) {
$newVisit = "true";
$startTime = date('h:i:s A');
} else {
$newVisit = "false";
$startTime = "";
}
$timeElapse = time() - $_COOKIE['lastRequest'];
} else {
$newVisit = "true";
$timeElapse = "";
$startTime = date('h:i:s A');
}
Shouldn't all the cookie be stored in the "root" or bottom level directory and not in the folders. If you need to see what I mean, click "jazz musicians" and then click on another link that takes you to a subfolder.
Hmmm i lost you
i have one cookie at all :
visitor
89991ba850cb661fd54d3f6377d6e79b
www.modernmusicians.com/
1536
1233573248
29753962
1376864608
29747927
*
lastRequest
1132164194
www.modernmusicians.com/
1056
2082528512
29821353
80017312
29747928
*
after open it agein
visitor
89991ba850cb661fd54d3f6377d6e79b
www.modernmusicians.com/
1536
1233573248
29753962
1376864608
29747927
*
lastRequest
1132164304
www.modernmusicians.com/
1056
3182528512
29821353
1175017312
29747928
*
Flash Gordon
11-16-2005, 06:39 PM
:D Oops. I'm using two different scripts, one to track users in PHP and one to track flash clicks. I didn't change one of the scripts properly.
DUH!!!!! :rolleyes:
BTW, thanks for all the help Xeef, and CyanBlue.
Change of topic, why do you day mySQL is "noob"? What database to you prefer? mySQL is the one that came with my webHost, I didn't have too much say over it. But at least I get unlimited 'noob' databases :)
MySQL is the most populair (woud i say)
so there will by the most info around
it's free
it hase a big functionality (as fare i know newer versions also suport loadbalancing over diferent server)
not see the point to learn a diferent one
where by the syntax shoud by more or less the same by the other ones
so it shoudn't by to hard to switch
Flash Gordon
11-16-2005, 07:03 PM
like :
if (isset($_GET["BLA"])){
if (isset($_COOKIE['visitor'])){"all OK"}else{Cookie not accepted}
}else{
setcookie('visitor', $user, time()+3600*24*30);
}
this coud by also made by 2 files
eg.
index.php -->just write the cookie and load MainIndex.php
if you have No cookie in MainIndex.php then index.php wasn't abel to set it
aditional tasks are needed
I think I have understood most stuff on this very long thread (I'll make a summary of it all at the end for future users) But the only thing, I still don't understand is how to check if the user accepted the cookie. Perhaps, I'm being rather dense about it. Whenever you get some free time, Xeef, could you hard code an example for me. I think seeing it in actual scripting would help my understanding.
Once again, I do sincerely appreciate all the help time you have spent with this thread. I believe it may be the first in AS[org] history that didn't get hi-jacked after 2 pages :p
EDIT: I think I may just have understood what you mean. Is this it:
//page1.php
<?php
setcookie("test", "foo", time()*300);
header("Location: page2.php");
?>
//page2.php
<?php
if(isset($_COOKIE['test'])) {
echo "user excepts cookie";
} else {
echo "user does not except cookies. Don't try to track by cookie.";
}
?>
The only problem with this is what if user goes straigth to page2.php and skips page1.php?
have no server in the moment to test :(
if you have a test acount no prob
Flash Gordon
11-16-2005, 09:35 PM
PMed you the info.
What happened to your server?
<?php
session_start();
if (isset($_GET['SID'])){
if (isset($_COOKIE['Xeef'])) {
echo "Cookie OK<br>";
}else{
echo "Cookie NOT OK<br>";
}
if (isset($_SESSION['Xeef'])) {
echo "SESSION Cookie OK<br>";
}else{
echo "SESSION Cookie NOT OK<br>";
}
}else{
setcookie ("Xeef", "Xeef", time()+3600);
header("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/Cookie.php?SID=".session_id());
$_SESSION['Xeef']="Xeef";
}
?>
seams to work ;)
server :
i have no creditcard (not like them like to have money in my pocket)
so the server was runing on the card of a friend who has 10 of them
and lose each week one :p
the servercontract was just on to renew and he just had lose the creditcard on wich it was runing
so they instantly cancel it whit out any future knowledge
or mayby not streight but i wasn't checking any email or the server it self for the last 10 days
Flash Gordon
11-17-2005, 12:43 AM
Thanks Xeef. I'll play with that script to see if I can get it to work for me.
I'll leave your account at my site up for a while, incase you need to test or play with some stuff. Just don't do any upload files to root directory :D
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.