Put the snake into a pillowcase. Put the pillowcase in a shallow plastic bin. Put the plastic bin under your covers with you at night.
The pillowcase + bin ensures that your snake can't escape, and the bin ensures that you won't roll over onto your snake while you sleep (or your cats and dogs won't step on it if they sleep in the bed), or if your snake pees you won't end up with soiled bedding.