Only start Session when Cookies enabled


i am using CDbHttpSession, so my sessions are stored in the database.

Unfortunately there is a lot of crawler/bot traffic on my website.

Yii opens for every request a new session, if cookies are not enabled at the client side.

This leads to huge database overload.

Is there a way to stop starting sessions, if cookies are not enabled?

(It takes now 12 hours to blast my Memory table with 16MB Limit)

Best regards,


I found same proble today!

Any solution?

Sessions are generally handled by PHP (server side) and cookies by browser (client side). Sure there are options / solutions to make one available on other side, but because in general these are two different sides of request handling procedure, I would assume that doing, what you’re asking for will be very hard, if not impossible.

Did you try simple "robots.txt" solutions?


It nearly always helps my sites to reduce unwanted traffic.

Just put:

User-agent: *

Disallow: /

to robots.txt file and place it in root of your site. Should help.

Or read above examples (or google for more) to get a more sophisticated solution.