Save javascript string on server

I have PHP up to 5.4, Perl 5.8, C and Python available on the server side.

So basically I have a JavaScript client side and I am generating a string. I would like to keep this line server side.

I know how to load a string from a file on the server using XMLHttpRequest

. But I don't like the idea of ​​using a file to simply store a string, even if it's large.

So I'm looking for an example from a string that goes from Javascript to PHP (or whatever is available to me) and back from PHP to JavaScript.

If it's not MySQL related, this is better (I just want to store the row). I have nothing about jQuery, but I have no plans to look at it right now.

EDIT 1: To clarify what I need, the user will connect to the game on the site using a JS app, and in the middle will save some simple things (string). I want after that when he comes back (or another user) to the site, he can get his stuff back.

EDIT 2: since it cannot be done as nnnnnn says in the comment. I changed the question to:
I would like to save the string while using the JS application and restore it for the next user.

EDIT 3: I am looking for a simple example to save a line in a file as no other solution is possible.

+3


source to share


2 answers


If I understand correctly:



  • send to server and save it to some temporary location (file, db, whatever)
  • next load, ask via ajax if there are any changes or saved data.
  • if yes upload them
  • If the data is javascript sode you can use the eval () code
  • Another rather dirty solution is the use of cookies.
  • You cannot expect the supported features in new browsers to be supported in older browsers, nor is it possible to find hidden locales.
+1


source


As I understand it, you want to exchange data between users. This way you send information to the server, and the server is responsible for providing the same data later. And you don't want to use the file as well as the database. The session is not suitable for storing big data.

Then, an alternative solution is to store your data on the Memcache server. It is more convenient in your case. But you must remember one thing about Memcache, that is, Memcache is not persistent storage. But you can increase the Memcache flush intervals as much as you like.



Note. Memcache is the process of consuming RAM.

+1


source







All Articles