Change the `cd` into a function to run the real `cd` and run your script afterward.

 cd () {
 if builtin cd ${1:+"$@"} && [ -r ./set_foo_env.sh ]; then
 . ./set_foo_env.sh
 fi
 }

This assumes that:

 1. The `set_foo_env.sh` would be specific to a single directories, and
 2. That `set_foo_env.sh` should change the existing shell's environment.

If you want path-based with a global file, then look at the question that manatwork mentioned ( http://unix.stackexchange.com/questions/21363/execute-bash-scripts-on-entering-a-directory).