• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

What is best way to persist data across web pages?


Active member
I'm creating an add-on that contains information I would like to persist between multiple pages from the users web browser.

I've been studying the cookies that xenforo uses for statefulness and I'm confused. When at I look at a submit form, it uses _xftoken, in the header cookie there is also xf_session, and when searches are performed there is a searchid that is used to page through search results.

So for my data, what is the recommended way to persist data across multiple pages?

I've successfully used in my controller the Xenforo_Session "get session" function, the "set session key" function, and the "save session" function across multiple pages. But I'm not sure if that's the way to go because I don't understand the other cookies being passed from the browser to the controller. Especially the _xftoken.


Active member
Thanks for the few replies I've received, but I find the participation here to really be underwhelming. :(

So, I'll answer my own question (based on the typical replies I read here).

Answer: Read all the xenforo code and the answer will then become obvious to even the most casual observer. o_O


Mr. Goodie2Shoes

Well-known member
_xfToken is just a "token" to prevent CSRF http://en.wikipedia.org/wiki/Cross-site_request_forgery

To persist data across multiple page visits for a visitor with the same session, XenForo_Session object would be your best bet.

You can access into the object by calling
Do note that you can only save data from a controller and after the dispatch the session object becomes "read-only" ;)

P.S. Look into XF's source for more info :p
Last edited:

Daniel Hood

Well-known member
Can also use cookies.

Look at /XenForo/Helper/Cookie.php for the exact parameters to use and set.