People are saying that this issue is USB-related, for example wireless mice and keyboards can wake your computer up from sleep. Anyway, the problem has occured when I didn't have ANYTHING connected to my macbook, so I'm not sure about that.
The solution I posted earlier should be working, the only difference is that you'll have to press a key or something to wake your computer up after you've opened the lid.