Type "M-x desktop-save RET RET". After that, "M-x desktop-read RET" will
restore the session. You can put
(desktop-load-default)
(desktop-read)
in your .emacs file, to make Emacs restore the last session automatically
when it starts.
See the commentary in the package desktop.el for details.