Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Force Cookie Use Prevent Spider Sessions


andreid_08

Recommended Posts

Oke, so I think I have a problem. I have a site that won't get indexed by google. I only have 20 out of 3500 pages indexed in google after 6 months. Now I try to get it optimised, so I use MOD REWRITE and I try to stop pages with OSCid=..... bla bla. So, i put Force Cookie Use TRUE and Prevent Spider Sessions TRUE. I think that here is a problem.

 

application_top.php :

 

$session_started = false;

if (SESSION_FORCE_COOKIE_USE == 'True') {

tep_setcookie('cookie_test', 'please_accept_for_session', time()+60*60*24*30, $cookie_path, $cookie_domain);

 

if (isset($HTTP_COOKIE_VARS['cookie_test'])) {

tep_session_start();

$session_started = true;

}

} elseif (SESSION_BLOCK_SPIDERS == 'True') {

$user_agent = strtolower(getenv('HTTP_USER_AGENT'));

$spider_flag = false;

 

if (tep_not_null($user_agent)) {

$spiders = file(DIR_WS_INCLUDES . 'spiders.txt');

 

for ($i=0, $n=sizeof($spiders); $i<$n; $i++) {

if (tep_not_null($spiders[$i])) {

if (is_integer(strpos($user_agent, trim($spiders[$i])))) {

$spider_flag = true;

break;

}

}

}

}

 

if ($spider_flag == false) {

tep_session_start();

$session_started = true;

}

} else {

tep_session_start();

$session_started = true;

}

 

 

The main problem here is that if both SESSION_FORCE_COOKIE_USE == 'True' and SESSION_BLOCK_SPIDERS == 'True' it will go in the first 'if clause' and only start a session with cookies, but that won't stop spiders from having their own session. I allready have some pages in google indexed like .html?osCsid=a0f30318422cddd9af8dab49588826b1, so when google comes back he gets back on the site with this session. Any ideea to stop that? I can think of rewriteing the if-else from the code in application_top.php but i'm not sure if this really is the problem or it can be solved in a different way. Any ideeas to get google stop indexing pages like .html?osCsid=a0f30318422cddd9af8dab49588826b1?

Link to comment
Share on other sites

I allready have some pages in google indexed like .html?osCsid=a0f30318422cddd9af8dab49588826b1

This means you have an seo contribution that transforms php to html pages.

 

Typically the spiders won't accept cookies (the major ones don't) so the first "if" will go through without starting the session. So $session_started = false stays for search engines. Also if you are forcing cookies you will never see a session with the url. And you can only force cookies on a dedicated server.

Link to comment
Share on other sites

the first 'if' sets up cookies and then starts the session. The problem is that even if the visior is a spider the session is started. I know that this is happening because I watch the 'who's online' section in admin>tools and google always comes with an OSCid=..... I'll probably rewrite the code tomorrow, so that it will deal the case when bots Force cookies and block spider session are TRUE, and the visitor is a spider.

Link to comment
Share on other sites

the first 'if' sets up cookies and then starts the session. The problem is that even if the visior is a spider the session is started. I know that this is happening because I watch the 'who's online' section in admin>tools and google always comes with an OSCid=..... I'll probably rewrite the code tomorrow, so that it will deal the case when bots Force cookies and block spider session are TRUE, and the visitor is a spider.

 

no because google bot will not accept a cookie so the first "if" fails.

	if (isset($HTTP_COOKIE_VARS['cookie_test'])) { // Will not fall through with most spiders including googlebot because they do not accept cookies
  tep_session_start();
  $session_started = true;
}

 

I think the problem is because you have some other customizations with your store like the seo urls. You have to set perhaps the spider flag if it is used by other modules.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...