Ok i made a small script, which sets a $_SESSION[$_SERVER[‘REMOTE_ADDR’]] the problem, it dont works with bots, if i go to my webpage and make page refresh it works, but it is not working with bots.
When i look in the session dir, i see 1000s of session files, with ips in it, but the session variable is always = 1, so my thinking, when the bot connects to my site, it always sets a new Session instead of increasing the session variable. Any idea how i can fix this. Here is my code:
<?php
session_start();
if(isset($_SESSION[$_SERVER['REMOTE_ADDR']])){
$_SESSION[$_SERVER['REMOTE_ADDR']]++;
if($_SESSION[$_SERVER['REMOTE_ADDR']] % 2 == 0) {
// DO SOMETHING
}
} else {
$_SESSION[$_SERVER['REMOTE_ADDR']] = 1;
}
?>
EDIT FOR JON:
That script above gets executed on all pages of my site:
The Session Variable: gets build so $_SERVER[‘REMOTE_ADDR’] for example is = 127.0.0.1
so my SESSION variable would be $_SESSION[‘127.0.0.1’];
So when the IP goes, to other pages of my site x,y,1,2,3,5 the $_SESSION[‘127.0.0.1’] variable gets an increment of 1
But this dont works for bots.
Jon i thought: SESSION are serverside, so that vars get stored on the server, i dont want set any cookies.
You cannot “fix” this. If someone wants to scrape parts of your site that do not require a session being in a specific state (e.g. logged in user) then they will not bother with storing your session id cookies and returning them to you. And without a session id, each time they will look like a new session to you.
What exactly are you trying to accomplish here?