You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Cannot find the ~/Library/Safari/LastSession.plist file

I am running macOS Sonoma 14.5. I am hoping to recover all the windows I had open in Safari from a session a few days ago, using Tim Machine. This information is supposed to be found here:


~/Library/Safari/LastSession.plist file


I have the option to show my home folder Library folder in the Finder enabled, so I can see the appropriate folder and can get to the Safari folder, but for the life of me I cannot find a file named "LastSession"


If fact, I cannot even find this file in the appropriate directory of my Mac itself.


Did Apple move the location of this file?

Mac Studio, macOS 14.5

Posted on Oct 29, 2024 12:06 PM

Reply
3 replies

Oct 30, 2024 1:41 PM in response to AppleITGuru

They more than moved it. The LastSession.plist is no longer used in Safari 18.*. Read the posts here that talk about the files you need to restore from Time Machine and their location. I would make backups of the existing mentioned files so they are not overwritten.


If you do not clear your Safari history frequently, then I wrote a sqlite3 solution that when run like this:

./sql_dtu.zsh > ~/Desktop/Safari_hist.csv


will give you a CSV that has the following fields: timestamp, Title, and URL string. Upon opening with Finder Quick Look in nice tabular format, one can right-click on the URL string, and from the Services menu, select Open URL and that will open a new tab in the default browser.


Code:


#!/bin/zsh

: <<'COMMENT'
Generate a CSV document with headers showing current Safari History
database content. You can view the columnar CSV in a scrollable QuickLook window,
or load it into a spreadsheet

Reference: http://2016.padjo.org/tutorials/sqlite-your-browser-history/

Usage in Terminal:
./sql_dtu.zsh > ~/Desktop/hist.csv

VikingOSX, 2020-07-16, Apple Support Communities, No warranties expressed or implied.
COMMENT

sqlite3 -header -csv $HOME/Library/Safari/History.db \
"SELECT DISTINCT
    datetime(visit_time + 978307200, 'unixepoch', 'localtime') AS visit_time,
    coalesce(nullif(title,''), 'Unavailable') as title, url
FROM
    history_visits
INNER JOIN
    history_items ON
        history_items.id = history_visits.history_item;"
exit 0

Tested with Safari 18.1 on macOS Sequoia v15.1 and Sonoma v14.7.

Cannot find the ~/Library/Safari/LastSession.plist file

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.