Jump to content

[SOLVED] What would be better?


ballhogjoni

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.