Preserving state across a "back"

I have a Javascript accordion.

The accordion starts in the completely closed state.

The accordion opens up to a bunch of links. If the user clicks on a
link it takes the user to a document that I have created and display.

What I want is for the user to be able to click on the back button and
have the accordion remember its state.

I'm not asking for Javacript help. I'm just wondering how in Rails I
can
detect that "I went to the document and that I am returning from the
document".

There is no username so I guess the info needs to go in the session
data.

Suggestions on how to preserve state across a "back' would be
appreciated.

I think the problem is that you do not send the request to the server
when you hit the back button.
That's why I can only imagine a js solution to your problem.
There are some good jquery and prototype plugins released that can be
helpful.
Take a look @ reallysimplehistory or YUI library: browser history
manager.