How to login as a different user in terminal?

Have you tried using su - foo?

Update based on the comments:

The empty - tells su to make a full login. That means (from the man page),

The environment is discarded except for HOME, SHELL, PATH, TERM, and USER. HOME and SHELL are modified as above. USER is set to the target login. PATH is set to ``/bin:/usr/bin''. TERM is imported from your current environment. The invoked shell is the target login's, and su will change directory to the target login's home directory.

So, if you need any other environment variables, such as DISPLAY to open programs that use the window server, you have to omit the empty -.