At 18.03.2002  14:54, you wrote:

Even if I didīnt look closely at your code, I would suggest, that
you decrease the amount of data, diferent tables to one table.
You set an cookie, therfor you have the same effect as if you use sesssion 
So itīs easy to set and find the data, via cookie.
cookie   // here the initial cookie, you sent is stored
varname  // what kind of information should be stored
varval // the value of the varname.
timestamp // if you like
now you can save all desired informations according to cookie, have them all
in one place, and can select them to different conditions.
But, what if the user doesnīt allow cookies ??
>I am a kind of newbie in PHP programming, but I have found an interesting
>problem and some php guys I know were unable to help me to solve it. So I am
>coming here with my question...
>I have written a little more advanced counter, which should be included in
>other PHP scripts in website.
>It uses cookies, which expire in one year. That helps me to determine which
>users are coming back to the website. It also uses sessions (session
>cookies) to detect how one user is moving in the website in one session.
>Program uses three MySQL tables - table of cookies (cookie ID, number of
>visits), table of sessions (session ID, cookie ID, IP, browser,...) and
>table of visited subpages in the website (session ID, visited location).
>The program flow is simple:
>1. Check the cookies. If user do not have a cookie, send it to him. Else
>find cookie ID in the database (first table) and increase the counter.
>2. Check session ID. If session is not registered, register it and set
>'number of session visits counter' to 1, AND save session ID (+ cookie ID,
>IP,...) to the second MySQL table.
>If session is already registered, just increase the session visits counter.
>3. Save session ID and visited location (I use the $REQUEST_URI variable) to
>the third MySQL table.
>It seems OK, but see what happened.
>I explicitely said that if ($sess_visits == 1), variable $sessid is saved to
>the second table. That means that $sessid must be unique - it should appear
>in a table just once.
>But when I exported data from table, I found that some $sessid appeared
>twice or three times!
>What could be the problem???
>See a little bit of my code:
>   ini_set("session.cookie_lifetime", "0");
>   // Initialize session
>   session_start();
>   // Register session and set number of session visits variable to 1
>   if (!session_is_registered('sess_visits')) {
>       session_register('sess_visits');
>       $sess_visits = 1;
>   }
>   else {
>     $sess_visits++;
>   }
>   if ($sess_visits == 1) {
>     // Save session, IP, etc. into database
>     $sql = "INSERT INTO wc_sessionident SET sessid = '$sessid', ...";
>   }
>bye, Matej
>PHP General Mailing List (
>To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to