: How to read user unique code from _ga cookie? Currently I am facing the problem that have been discussed already here: How to keep track of a unique and an existing visitor (keep track about
Currently I am facing the problem that have been discussed already here: How to keep track of a unique and an existing visitor (keep track about unique user without registration etc.). The most suitable answer was: "Try _ga cookie". So my questestion is how can I do that on my PHP website?
I want something like this:
User came to my website and performs some action
I "look into his _ga cookie" and take some "identification code"
I log about this action to the database
When user will come again and he will want to perform action again, then I look into my log and I will realize that this is same user
My question is:
How to read user identification from _ga ?
More posts by @Ravi8258870
1 Comments
Sorted by latest first Latest Oldest Best
Just get _ga cookie - it is a string with dot separated values. You are looking for third value...
public static function getGaCode() {
// Check fo cookie
$name = "_ga";
if (!isset($_COOKIE[$name])) {
return null;
}
// Parse cookie _ga='<something>.<something>.<clientid>.<timestamp>';
return explode(".", $_COOKIE[$name])[2];
}
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.