Question: I use [Sessions](https://sessions-extension.github.io/Sessions/) to keep track of browsing sessions in Safari. I was having some trouble with invalid cookies and I cleared my web history. Now all of my saved Sessions are gone. Is there any way to recover the data? Where does Sessions store it's data? I may have a backup.

Answer: 
If you go to Sessions "Help" (in the gear menu), there are two questions relevant to your issue:

> 
> Why did my saved sessions disappear when I reset Safari or cleared its
>  history?
> 
> 
> The option to remove website data, available when either resetting
>  Safari or clearing its history, will delete extension data without
>  warning. Some third-party cache cleaners may do the same. It is
>  recommended to take care when using these tools, as any data so
>  deleted can only be recovered from a backup.
> 
> 
> 

and more importantly for you:

> 
> How do I recover Sessions data from a Time Machine or other backup?
> 
> 
> If you are familiar with the command line, try using the
>  `sessions-export` script. This is the recommended procedure.
>  Alternatively, it is possible to physically replace the database file
>  with a backup. The .db file under the directory
>  `~/Library/Safari/Databases/safari-extension_yoo.david.sessions-deub45nr9t_0/`
>  can be replaced by a recovered file if the latter is renamed to match
>  the file it replaces.
> 
> 
> 

So, if you have a backup, it should be as easy as a copy and maybe a rename.
Sessions seems to store its data in the browser's javascript database which, per [this stackoverflow posting](https://stackoverflow.com/a/4735298/318902), is in `~/Library/Safari/Databases`.

In fact, I see a directory in mine called something like `safari-extension_yoo.david.sessions-<random number>`. The contents appear to be an SQLite database:

```
$ file *
0000000000000001.db:     SQLite 3.x database, last written using SQLite version 3008010
0000000000000001.db-shm: data
0000000000000001.db-wal: SQLite Write-Ahead Log, version 3007000

```

Using `sqlite3` per the instructions [here](https://apple.stackexchange.com/a/115840/10389) and [here](https://www.sqlite.org/cli.html), I can see what looks to be interesting data:

```
$ sqlite3 *.db
SQLite version 3.16.0 2016-11-04 19:09:39
Enter ".help" for usage hints.
sqlite> .tables
__WebKitDatabaseInfoTable__  tabs                       
favorites                    tabs_windows_sessions      
sessions                     windows                    
sqlite> select * from sessions;
1|1381010647|◆ 2013-10-05 18:04:04
2|1381011556|◆ 2013-10-05 18:19:16
3|1381283711|◆ 2013-10-08 21:55:10
4|1381419556|◆ 2013-10-10 11:39:15
...

```