The secret is contentment. Be content with what you have. If you are content you are not going to base your happiness on owning the latest gadgets. This will serve as a protection because you are not going to be tempted to live beyond your means.
Also before I make any purchases I ask the following questions: Do I need it? Can I afford it? Why is it that I want this item? These questions usually keep me in check.