0

I'm using JS Objects to sort and filter a table but I need to store the original table data in case the user wants to return to it. I'm just wondering if there's an easy way to pass the object's data to a PHP session var, via AJAX, and retain stuff like the key/value relationships without doing a lot of heavy lifting.

4
  • Where are you getting the table data to begin with? Commented Jan 17, 2011 at 16:17
  • mysql query - I do store the original query in a session so I guess, duh, I could just resubmit it. Commented Jan 17, 2011 at 16:32
  • 1
    Yeah that's kind of where I was going with that question. Commented Jan 17, 2011 at 16:35
  • Pointing out my inefficiencies of thought is so unkind... : D Commented Jan 17, 2011 at 16:42

2 Answers 2

2

Build a JSON-string of the object and store this string. JSON.stringify

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Dr.Molle, I've never worked with JSON before, I'll check it out.
php has json_encode and json_decode functions to make the JSON to/from process even easier.
0

It's not possible.

On the client side, the session is identified by a cookie. The session ID is all you've got.

On the server, the session data is stored in a binary file, one file per session (typical scenario).

So you can't touch the contents from the session from the browser without help from the server.

And second: it's not "light". In an app I've been working on, modern computer and virtually no load yet, loading the session seem to be taking around 250ms, 10 times longer than the response time for the whole page when starting from scratch.

In summary:

  1. you cannot touch session variables without writing a script on the server that handles the data
  2. It's not "light".

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.