PHP Script Issues (Reading Cookies)
Hi, On my site im trying to make a skin selector. The skin chooser saves your preference in a cookie.
here is my index.php Code:
<? loadskin.php reads your cookie, and determines what skin you wanted to use. It then loads the filepath to the template file and saves it as $path. loadskin.php Code:
<?php The script works perfectly, it remembers what skin you chose, and it loads it correctly. Now, here is the problem. When ever I enable my new template system, my server loads go over 20 all of a sudden, and it crashes my server. I am getting extremely high traffic, 30 queries a second, 70k unique hits daily. My server is getting a lot of traffic as it is, but my site uses a very well made search engine with 5 hour caching. Server loads are under 0.5 during peak hours. Its obvious that the skin selector is causing the loads. Can someone please help me fix this problem. Is there a better way to write this code without causing such a high load? Thanks, -Remus. |
i would place
if(($sskin <> 1) && ($skin <> 2)){ $sskin = "1"; } before the switch. Now it is placed behind the last break - maybe this is causing an internal error. Is there a typo in the 2nd comparison ? |
Yea, I just noticed that the IF statement was within the switch.
I moved it after, but I am still having the high server load issues. |
Well NVM, I solved the problem. I now store information in MySQL tables by IP instead - Works a lot faster than cookies.
|
well, maybe works, but what for users having a dial up connection, thus getting a new IP whenever they connect to the internet (or DSL, at least in germany, many providers disconnect after 24 hours).
Normally, the php cookie code doesn't make such load problems, on my site it works without problems. maybe your cookie SET-code is buggy? if you can post it, I'll have a glance on it. PS: why the empty string before $path in your include statement? include($path.'index.php') should be enough. |
All times are GMT -5. The time now is 04:55 PM. |