Skip to content
Pine Computer Request access
Menu

Blog

Cookbook 04: Sign in once. Stay signed in.

Sign in on a Pine Computer, stop it and attach again for another task. See the recorded Ruby example of reusing a saved browser login.

By The Pine Computer team · Updated

Cookbook 04: Sign in once. Stay signed in.

Two programs, two hours apart, on one computer.

The first signs in to Amazon. When Amazon texts a code, the run asks for it in the terminal and the person types it in. Then the program stops the computer.

Two hours later, the second program brings the same computer back and opens a new session. Amazon recognizes the account without another sign-in. The requested EarPods are already in the cart; the agent checks the product and leaves the quantity at one. It does not place an order.

That distinction matters when resuming a task. The first thing to establish is the site’s current state. Repeating the previous instruction without checking it could add the item twice.

What the two programs keep

The first program’s computer identity and credentials are saved by the demo’s setup code. The second reads them through load_computer and attaches to that same computer. Creating a different computer would not restore this account’s saved browser state.

The following excerpts are the Ruby shown in the recording. follow handles the agent’s output and questions, including the sign-in code. load_computer is a local helper, not an SDK method; its implementation is omitted here. The getting-started guide covers client setup and saving the credentials on your backend.

The Ruby below is an excerpt from the October recording, not a current integration recipe. SDK setup and application helpers are omitted. Use the current agent API and file handling docs when building an integration.

Ruby
# signin.rb
computer = pine.create_computer

a = computer.create_session(browser: true)
a.agent.run("Sign in to amazon.com as $EMAIL. If it asks for a code, ask me.",
  secrets: { "EMAIL" => ENV["AMAZON_EMAIL"] })
follow(a)
gets  # press Enter to stop
puts "Stopping the computer…"
computer.stop
Ruby
# buy.rb
id, saved = load_computer
computer = pine.attach_computer(id, **saved)   # the same computer, back

session = computer.create_session(browser: true)
session.agent.run("Add Apple's wired EarPods with a USB-C plug to the cart on
  amazon.com.")
follow(session)

gets  # press Enter to stop
puts "Stopping the computer…"
computer.stop

What came back, and what did not

The second program creates a fresh session. The recording demonstrates restored access to an account, rather than a resumed tab, conversation or working directory. The cart is data on Amazon’s side; seeing it again does not demonstrate that Pine saved a local file.

Pine can restore supported browser state, but recovery is best effort and the website can expire a login. Tabs, sessions, working files and downloads do not survive a stop. Save finished work in your own storage before stopping. The persistence documentation lists what is saved and how restoration works.

Resume the job against the account you find

Keep the customer-to-computer mapping alongside the unfinished task. After attaching, check which account the site shows before doing account-specific work. If the site requests authentication, bring that customer back to sign in; do not treat a fresh session as proof that access was restored.

For this shopping task, the useful check is the exact product and quantity already in the cart. For an invoice task it would be the existing invoice or confirmation reference. Preserve that result outside the computer so the next worker knows which action, if any, remains unfinished.

Both programs were recorded on October 7, 2026, with a gap of two hours and four minutes. This is one observed recovery on Amazon, not a guarantee that every website will retain access for that duration.

More from the blog

Build more.
Hand AI the work.