March 13, 2016 will

Test multiple user accounts without logging out

Have you ever needed to test multiple user accounts in your web app?

If you need to check your permissions are working correctly, you might find you are constantly switching users by logging in and logging out. Or you could have an admin user signed in to Chrome, and another user signed in to Firefox. Either way, its a bit of a pain.

Here's a simpler solution; define multiple aliases to 127.0.0.1 in your /etc/hosts file. That way you can have one tab open at http://adminuser:8000/ and another open at http://user1:8000/ with two entirely different user accounts.

This assumes of course that you have a development server running locally, and that your app is configured to serve to these 'domains'.

For example (append this to /etc/hosts):

127.0.0.1    adminuser
127.0.0.1    user1
127.0.0.1    user2

Not sure if this trick is common knowledge. But it literally just occurred to me.

Use Markdown for formatting
*Italic* **Bold** `inline code` Links to [Google](http://www.google.com) > This is a quote > ```python import this ```
your comment will be previewed here
gravatar
Matthew Schinckel

Even better: localtest.me

You can have any number of sub-domains applied, always resolves to 127.0.0.1

gravatar
Will McGugan

Aha! That's cool.