Welcome Guest, Not a member yet? Register   Sign In
Existing library/module: Code to track visitor's unique id in cookies?
#1

[eluser]Fero[/eluser]
Hi, is there any library/helper/module, whatever that helps to track customers?

I'd need to get unique number to every visitor (shopping cart list memory). Is there something outthere to use straightaway? What I need is just unique ID of every visitor, check that it's him/her.. :-)
#2

[eluser]drewbee[/eluser]
First of all, you never use IP's to a track a user as they can change or easily be manipulated.

Second of all, take a look at the session class http://ellislab.com/codeigniter/user-gui...sions.html

Should be exactly what you are looking for.
#3

[eluser]Fero[/eluser]
but session class regenerates the session_id every 5 minutes. I need to keep that ID for the lifetime of the cookie OR with regeneration of the ID I'd need to update the DB - table containg the shopping cart of user.
#4

[eluser]drewbee[/eluser]
Why not store this shopping cart information in the session variables? Why are you trying to save them to the database if they are not permanently associated with a user?

Anyways, even though CI can generate a new session id, you could save an string to your session if you want to store actual temp cart details in a database.

- when user enters page, save to session $unique_id = md5(session_id + ip_address)
- when user enters item to cart, use $unique_id;

If CI regenerates session_id, it doesn't matter, because you are tracking the user in the DB by $unique_id, which will stay consistent in the session even if the session_id changes.

Does that make sense?
#5

[eluser]Fero[/eluser]
The idea of storing shopping cart in session didn't cross my mind, good one. thank you
#6

[eluser]drewbee[/eluser]
No problem. IMO makes it much easier to manage Smile You will now only have records in your DB of actual items that have been committed to being purchased, of which you can associate the records to an actual user account.
#7

[eluser]Tom Schlick[/eluser]
just a note to this. there is a nice cart library in the svn version of CI. if you wanna save yourself some hassle id take a look at it Smile
#8

[eluser]drewbee[/eluser]
Nice! Didn't know about that. It has some nice features that may be worth looking at.
#9

[eluser]Fero[/eluser]
erm, svn version? how do i get that?
#10

[eluser]drewbee[/eluser]
In the simplest form,

Go to Codeigniter > Downloads > visit the svn trunk and find system/libraries/cart.php for the plain text

http://dev.ellislab.com/svn/CodeIgniter/...s/Cart.php


Or you could do a checkout if you have some type of svn setup.

Edit: Remember this is in the SVN, so their may still be some bugs associated with it. It hasn't been 'officially' released yet.




Theme © iAndrew 2016 - Forum software by © MyBB