also you may try desktop-save-mode:
desktop-save-mode is an interactive autoloaded Lisp function.
(desktop-save-mode &optional ARG)
Toggle desktop saving (Desktop Save mode). With a prefix argument ARG, enable Desktop Save mode if ARG is positive, and disable it otherwise. If called from Lisp, enable the mode if ARG is omitted or nil.
If Desktop Save mode is enabled, the state of Emacs is saved from
one session to another. See variable desktop-save' and function
desktop-read' for details.