Website Design United States, Website Design California, Website Designing United States, Website Designing California

Avoid session IDs to aid in search engine indexing - PHP

Web sites use session IDs to track your progress through the site and keep your information with you. However, this is unnecessary on many sites until the user logs in because there is no session information to carry over. Session information is generally stored in a cookie, but if cookies are disabled, PHP will create and append a session ID to the page URL. While this is good for the normal user, it can cause problems for search engine indexing.

Search engine spiders do not accept cookies. If they index your page and are displayed a session ID, they will not index the actual page. This will hurt your page ranking.

This code sample is a way to avoid session IDs on pages until a user is logged in. This method consists of three steps:

Start the session
Check to see if a specific session variable exists
If it does not, destroy the session.

This code should not be used on your login or logout pages.

<?php
session_start(); // start the session
header("Cache-control: private"); // IE 6 bug fix
// check to see if the name session variable is set
// you can use any variable being set by the session in place of name
if($_SESSION['name'])
{
// add additional code you might have if a session is running
// code in here might include gathering cookie information
// or performing an auto login
}
else
{
// destroy the session to aid the search engines indexing
session_destroy();
}
?>

WEB DESIGN INDIA
42 B Malviya Nagar , New Delhi-110017

Skype: manmeetsi
Email: support.webdesignindia@gmail.com
Tel: 91-011-40502005, 9810067295

 















 


© 2008-2009 dotnet4all.com