开发者

javascript object: is there a way to store in a PHP session var?

开发者 https://www.devze.com 2023-02-05 06:47 出处:网络
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 d

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.


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


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".
0

精彩评论

暂无评论...
验证码 换一张
取 消