2

I am looking for application development in such a way that it should work whether the user has an Internet connection or not.

I am working on a mobile PHP/MySQL based application. Sometimes an Internet connection is not available at the required place. I want to keep the database in a buffer and want to update it as it gets connected with the Internet, so that the application can work without any interruptions.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
user1724124
  • 99
  • 1
  • 6
  • 3
    If the question is "can you?", the answer is yes, otherwise you need to ask an a bit more specific question. A "mobile application" can be a lot of different things. – Joachim Isaksson Oct 07 '12 at 11:02
  • 1
    What kind of mobile operating system ? Please tag the question with the relevant mobile OS. – Jack Brown Oct 07 '12 at 11:10

2 Answers2

3

Depending on how much data you need to be persistent on the client's machine, you might be able to use cookies to save this data.

Here is a simple example of storing some information in cookies

// set the cookies
setcookie("someInfo[key1]", "4815162342");
setcookie("anotherValue", "foobar");

Now, after you have set the cookie, you'll be able to retrieve the data on other pages from the same domain.

echo $_COOKIE['anotherValue']; 
// prints "foobar"

print_r($_COOKIE['someInfo']);
// Array(
//  'key1'=>"4815162342"
// )

Reference -

Lix
  • 47,311
  • 12
  • 103
  • 131
  • 1
    This will probably work with users who are not technically advanced. Other people will regurarly clear their cookies. Also, storing a complete database will consume a lot of memory space. user1724124 might need to think about the most efficient way to store his info. – Rick Slinkman Oct 07 '12 at 11:12
  • @ric - Very true. My mobile browser is set to remove all cache/history/cookies every time it exits, so this is probably not the most persistent way to store data locally. With regard to the size you are also correct and my answer does reference the size consideration. – Lix Oct 07 '12 at 11:14
3

You can use Web Storage

Web storage and DOM storage (document object model) are web application software methods and protocols used for storing data in a web browser. Web storage supports persistent data storage, similar to cookies but with a greatly enhanced capacity and no information stored in the HTTP request header. There are two main web storage types: local storage and session storage, behaving similarly to persistent cookies and session cookies respectively.

But that's about it in terms of reasonable data storage on the client

Also see

Community
  • 1
  • 1
Gordon
  • 312,688
  • 75
  • 539
  • 559