Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tracking user activity in the DB using cookies and Session() object 1

Status
Not open for further replies.

ericnet

Programmer
Mar 29, 2006
106
0
0
I want to collect user information and activity for each visit in my website. To do so I was thinking in use one cookie to identify user (or machine), this cookie would be ‘permanent’ in user’s machine, and use another cookie to identify every session that will be eliminated when user closes the browser or similar.

My site has also a private area where users can access previous registration and log in (this private area uses Session() object), but the rest of the site no log in is needed. Then, if user logs in during the visit, I would also store his/her user id in the user’s session information in the DB.

So in the database I would store:

-Sessions Table-
Session_id (cookie with session number)
User_num (if user logs in) Is the user id in the DB for registered users
Machine_cookie (permanent cookie that identifies the machine)
User_type (Registered or Anonymous) Registered when user logs in during the session, and Anonymous if user doesn’ t log in
IP_address
User_Agent
Is_Carwler (‘True’ or ‘False’)
Browser_name (i.e. IE)
Browser_version (i.e. 6.0)
Javascript_enabled (‘True’ or ‘False’)
Cookies_enabled (‘True’ or ‘False’)
UrlReferrer


Is this a good way to track user activity using cookies in combination with ASP.NET
Session() object?

More ideas, suggestions?

Thank you
 
and use another cookie to identify every session that will be eliminated when user closes the browser or similar.
That part of your idea isn't a very viable option (how is the server supposed to know when a client has closed their browser window?).

Apart from that, it seems to be OK if that is the type of information you are looking to gather from clients.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Hi ca8msm,

Ok. This is my basis plan, anyway I still have some doubts since I never implemented a system to follow users and record the activity.

If the client browser loses the permanent cookie that identifies the machine, What’ s the normal thing to do? And if the session cookie is lost (but not the real user’s session)?
Is it possible to lose machine’s permanent cookie (during a session) and still exists session’s cookie?

And what do you think about consider only registered sessions (fill the ‘User_num’ field with user id and the field ‘User_type’ as Registered) when user logs in (enters in the private area) during a session? So, when from the same client browser another session is done, but without log in, then ‘User_num’ will be null, and ‘User_type’ will be Anonymous, but the rest of the fields (Machine_cookie, IP_address, User_Agent,…) will be the same because this information is retrieved for every started session.

Thank you

 
Well, I guess that my questions are not too complicate, simply:

If the client browser loses the permanent cookie that identifies the machine, What’ s the normal thing to do?
Give simply another permanent cookie with new id. I will continue identifying the machine with the IP address or when the user logs in again. And I will know that the permanent cookie was lost.

And if the session cookie is lost (but not the real user’s session)?
Simply give another session’ s cookie and start another session. I will know that something strange happened, because two identical session data are registered in a very little elapsed time.


Is it possible to lose machine’s permanent cookie (during a session) and still exists session’s cookie?
Yes. So, simply take it in consideration when writing the code logic in the aspx page.


And what do you think about consider only registered sessions (fill the ‘User_num’ field with user id and the field ‘User_type’ as Registered) when user logs in (enters in the private area) during a session?….
That’ s ok. Since I can have sessions from the same machine that are of different users, so can exist sessions that are not of registered user.

And that’ s all (for the moment..) :)

Thank you to read and give me your approval
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top