I use javascript to detect visitor information such as generate a visitor id base on micro second, get screen size, os version and brower version.
It works when I test it. However, when the page goes live, there sometimes cannot get those information. This problem presents as the fields about those information are empty meaning ”. But I have set fields to not NULL and default is undefined.
I was think about that whether the visitor disable javascript but this can’t happen because I use ajax to send request, so javascript must be enable, otherwise it won’t be recorded in database.
So, what factor will occur this problem?
because the code is too long, so i just can post get id function here
function Initvisiter_id(){
var visiter_id;
//alert(sessionStorage.getItem('visiter_id'));
var date=new Date();
visiter_id = date.getTime() + Math.floor(Math.random()*1000001);
return visiter_id;
}
server side script to get the request from url
//get parameters from url
$parameters = $_GET['parameters'];
$parameters = str_replace('\\','',$parameters);
$m = json_decode($parameters);
The javascript is executed on the client. The client can give you or not give you whichever information it wants.
Also, I can reach your URL like this: http://bla.com/url?parameters=
It’s not an ajax request, yet it’s an URL I follow without javascript. For example, search engines spiders might follow your requests using this way.
Relying on client side informations to generate your IDs cannot be done. Never trust the client.
And because I just saw this link, it might be worth sharing in this context: http://minimaxir.com/2012/10/client-side-validation-is-hard-mode/