You get Protected status once you've been successfully attacked by another player. Assuming you get attacked on day x, it lasts until the earlier of:
- Your first login on day x, if you haven't already logged in that day,
- Your first login on day x+1, if you logged in on day x before being attacked,
- Midnight at the end of day x+1.

The end result is that you won't get attacked more than once a day on average, but if you stop logging in you can still get attacked every couple of days.