Forum Moderators: coopster

Message Too Old, No Replies

.htaccess transparent SESHID and sessions

Using .htaccess to supress PHPSESSID but site fails when cookies blocked

         

hughie

3:06 pm on Jan 6, 2005 (gmt 0)

10+ Year Member



just putting the finishing touches on a shopping site and have run into errors in the process when users are blocking cookies.

i am using
<IfModule mod_php4.c>
php_value session.use_trans_sid 0
</IfModule>
in my .htacess file to supress the PHPSESSID=22y3213etc. but it means that if a cookie isn't set the site fails to work properly.

if i remove that from my .htaccess the site works fine because the PHPSESSID is passed around evey page, but it knackers things for SEO purposes.

Is there a way i can do:
if (isset(cookie))
{
supress PHPSESSID;
}
else
{
dont supress PHPSESSID;
}
any help would be much appreciated!

damn seo always throws a spanner in the works ;-)

Cheers,
hughie

ergophobe

9:55 pm on Jan 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You can decide what serach engines you care about and not set sessions if the user agent is one of those. For example, in pseudo code

if (user agent is NOT on my list of search engines)
{
DO start a session;
}
else if user agent is on my list
{
do NOT start a session
}

Then you don't have to worry. If the user has cookies enabled, the session won't be in the URL by default.

The only bad thing about using sesisons in URLs for human users is that if people without cookies bookmark a page, the url will be invalid once the session expires. Make sure that if the session is invalid, the user goes to someplace logical (ideally, the intended page, but with a new session ID generated).

hughie

12:13 pm on Jan 7, 2005 (gmt 0)

10+ Year Member



Cheers for that, i think thats's the only way to do it.

most people do allow cookies so they will only see the SESSID on the second page they hit so not a major worry.

Cheers for the advice,
Hughie