CodeIgniter Forums
Using cookie to track users - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Using cookie to track users (/showthread.php?tid=63787)

Pages: 1 2


Using cookie to track users - Hamed - 12-10-2015

Hello,
I want to track my users while browsing my website how can I do this job?


RE: Using cookie to track users - solidcodes - 12-10-2015

First step you need to use User Authentication.

Community-Auth
IonAuth2

just google.

How do you want to track your users?


RE: Using cookie to track users - Hamed - 12-10-2015

My site doesn't have login, I want to trace my visitors.


RE: Using cookie to track users - Diederik - 12-10-2015

Tracking a visitor has nothing to do with authentication...

For simple statistics the easiest thing you could do is use a session and store each pageview in a database with a timestamp, session_id and current url. That way you can track how many pages an average user visists etc.
But you could just rely on some external statistics like Google analytics, Piwik etc.


RE: Using cookie to track users - Hamed - 12-11-2015

I want to track myself can you explain more?


RE: Using cookie to track users - cartalot - 12-11-2015

there are two ways to track someone while they are going to page to page. You can write some kind of ID to their cookie, and then retrieve that ID on the next page load. You can then use that ID to retrieve and write information to a database table such as what page they just went to. This does rely on cookies working on the visitors web browser. You can write / read the ID directly to / from the cookie, but using codeigniter 'sessions' gives you much more functionality. any information written to a cookie is unique to the visitor, but its not private - its part of the http headers that are sent by the browser.

The other way to track page to page is to create an ID, but instead of writing it to the cookie, you pass it in a hidden form field or added to the URL string. then when the person goes to the next page, you get the ID, retrieve and write the info, etc etc.


RE: Using cookie to track users - solidcodes - 12-11-2015

(12-10-2015, 05:40 AM)Diederik Wrote: Tracking a visitor has nothing to do with authentication...

For simple statistics the easiest thing you could do is use a session and store each pageview in a database with a timestamp, session_id and current url. That way you can track how many pages an average user visists etc.
But you could just rely on some external statistics like Google analytics, Piwik etc.

Using authentication is the most complete and proper way.
Because session is on, ip is recorded etc...


RE: Using cookie to track users - scion - 12-13-2015

(12-10-2015, 12:12 AM)Hamed Wrote: Hello,
I want to track my users while browsing my website how can I do this job?

What kind of tracking u need? What information?

Implement by yourself those system dont make sense to me. For this just try to use statistic, for exmaple Google capabilities

anyway if decide to implement then u need to write to your database information info about user actions, for exapmle mb IP

addresses

Best wishes, Scion


RE: Using cookie to track users - Hamed - 12-18-2015

I want to save cookie id in user browser and after that find return user and path they browsed my website.


RE: Using cookie to track users - Hamed - 12-20-2015

What is want to is this:
1-User visit my website for 1st time
2-I save a cookie in user visitor
3-I track user url
4-user exit my website
5-user return to my website for next time
6-with saved cookie I found user visited my website last time.