ballhogjoni Posted September 30, 2008 Share Posted September 30, 2008 I have a script that tests which country a site visitor is from. If the visitor is from a country that I don't allow to view my site, then the script will die. Would it be better to run this script each time a visitor goes from one page to another, or should I start a session and based off that session allow access to my site? I hope that made sense. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted September 30, 2008 Share Posted September 30, 2008 You could include that script in say, a header file for each script if you wanted. Quote Link to comment Share on other sites More sharing options...
discomatt Posted September 30, 2008 Share Posted September 30, 2008 Sessions are kept persistent by the user. If they really wanted to, they can delete the session cookie forcing a new session to start. I wouldn't bother. You could use both, checking the session, then checking the IP but consider this 'best-case' situation. You have 1000 visitors... 5 of them are banned. For those 5, they keep the session cookie. Your script checks for the session, and detects it. You don't have to poll the database to check if the user is banned - You save some processing time. This happens 5 times. Your script checks for the session, and it doesn't exist. You check the database to see if the user should be banned. It comes up false. This happens 995 times. As you can see.. only .1% of your user base is banned, and now you're forcing the vast majority to perform 2 checks instead of 1. You're better off with only a single check, as the time saved not having to check the banned user is probably lost in having to run multiple checks in legitimate users. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.