mthpvg
mthpvg

Reputation: 3819

Save a javascript string in the server

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

So basically I have JavaScript client-side and I'm generating a string. I'd like to save this string server-side.

I know how to load a string from a file in the server with XMLHttpRequest. But I don't like the idea to use a file for just storing a string even if it's a big one.

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

If it does not involved MySQL it is better (I just want to save a string). I have nothing about jQUERY but I'm not planning to look into it right now.

EDIT 1 : To precise what I need, the user will connect to the website play with the JS application and in the middle save some simple stuff (the string). I want that afterward when he'll come back (or another user) to the website 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'd like to save a string during the use of a JS application and restore it for the next user.

EDIT 3 : I'm looking for a simple example for saving the string in a file, as no other solution is feasible.

Upvotes: 3

Views: 522

Answers (2)

HILARUDEEN S ALLAUDEEN
HILARUDEEN S ALLAUDEEN

Reputation: 1752

As per my understanding, you want to share data between user. So that, you are sending information to the server and server is responsible to give the same data later. And you dont want to use file as well as database. Session is not suitable to keep large data.

Then, An alternate solution is store your data in Memcache server. This is more suitable in your case. But you have to remember one thing about Memcache, That is, Memcache is not persistent storage. But you can increase Memcache flushing interval as much as you want.

Note: Memcache is RAM consuming process.

Upvotes: 1

tomis
tomis

Reputation: 1971

If I understand correctly:

  1. send needed to server and save it to some temporary place (file, db, whatever)
  2. next load, ask via ajax if there is any change or data saved
  3. if so, load them
  4. if data are javascript sode, you can use eval() code
  5. Another, quite dirty solution is use cookie data
  6. You cannot expect that supported features in new browsers are supported in old ones as well - savind localy is not possible.

Upvotes: 1

Related Questions