473,396 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

php session tracking and MySQL?

I am a php newbie. I would like to count how many times a user visit a
webpage.
I know session tracking should be used, but where i put the code? Is it
inside the html that the user visit?

session_start();
if (!IsSet($page_number))
$page_number = 1;
print("You have now visited $page_number");
print(" of pages <br />");
$page_number++;
$session_register("page_number");

Also, i want to record the number of time a user visit a page and store
it in MySQL. I know how to do it using "form action and submit" way,
but
have no clue of doing it with session tracking .

Jul 17 '05 #1
1 2734
On 30 May 2005 09:34:29 -0700 (more or less), ma*****@hotmail.com wrote:
I am a php newbie. I would like to count how many times a user visit a
webpage.
I know session tracking should be used, but where i put the code? Is it
inside the html that the user visit?

session_start();
if (!IsSet($page_number))
$page_number = 1;
print("You have now visited $page_number");
print(" of pages <br />");
$page_number++;
$session_register("page_number");

Also, i want to record the number of time a user visit a page and store
it in MySQL. I know how to do it using "form action and submit" way,
but
have no clue of doing it with session tracking .


You can't do what you want with session cookes. You'll need to create a
permanent (or at least long duration) cookie for a visitor.

Something like:

// look for an existing cookie for this site

if (isset($_COOKIE['$thispage'])) { // if found, increment the count in
the database
update_db($user_code,$thispage);
}

// set a cookie (or extend the life of the current one

setcookie($aUniqueID,$thispage,time()+60*60*24*30) ;
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: marslee | last post by:
I want to prevent non-registered users to view a page in my website, For example, when a non-registered user clicks the history page, the website site refuses to go there since he is not...
2
by: David Frauzel | last post by:
I'm writing a rough draft of a suite of small Perl apps that will, combined, serve as a web site's user sign-up, login, management, and customized content engine. I'm having trouble with the...
4
by: Adil Akram | last post by:
I've developed a shopping cart app in ASP, to secure transaction by SSL, it 've put only the checkout page in SSL but all other pages i.e. product, cart etc remains on non SSL connection. How can I...
1
by: James | last post by:
Hello, I'm designing an online shopping cart using ASP. I want the flexibility of session tracking by using URL rewriting but I don't know how I would go about this. I'd like to know how I...
6
by: Patrick Olurotimi Ige | last post by:
I'm tracking usersOnline by adding this code below in my Global.asax file.But i noticed that when a user logs in it keeps adding a new user which thats fine..but when a user logs of it still...
9
by: Sullivan WxPyQtKinter | last post by:
I do not want to use Cookies in my site since not all web browser support it well and sometimes people close cookie functioning for security reasons. I tried to add hidden field with a sessionID...
1
by: Nospam | last post by:
Does anyone know of any session management with mysql scripts that uses cj tracking?
1
by: Franky | last post by:
Users can log into my site via a php login script or registration form (for new users). Login checks that the credentials are correct, and the registration creates a new entry in a mysql db. At...
43
by: davidkoree | last post by:
I mean not about cookie. Does it have something to do with operating system or browser plugin? I appreciate any help.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.