Save html in cookie

I use jquery to clone and add some html to the div.

My problem is that this html will be deleted when the page is refreshed. The question is how can I save the added HTML in a div (the html code will contain some inputs and select lists, and there will be a lot of code).

What should I look at?

Cookies?

HTML5?

Anything else?

+3
source share
5 answers

If you are only going to support modern browsers, I would go for HTML5 offline storage.

Another approach would be to get an AJAX route.

You do not want to use cookies for this, bacause:

cookies are loaded for every request

A cookie may contain only a limited amount of information.

+3

jquery. html5, html5, . , JQUERY STORAGE :

$.Storage.set("name", "value");

:

$.Storage.get("name");

, , , , ( ).

+3

HTML cookie... 1 . "" cookie, HTML- ( , , AJAX.)

, AJAX , . / , , , ​​ .

RFC 2109

[1] RFC 2109 - section 6.3 (on HTTP Cookies)
    4096 bytes per cookie
    20 cookies per unique host or domain name
0

<php
function getVar($name, $def = '') {
  if (isset($_REQUEST[$name]))
    return $_REQUEST[$name];
  else 
    return $def;
}


// check if overrides passed
$efind = getVar('q', '');
?>

<input type="text" name="q"  onFocus="this.value=''" onBlur="if(this.value == '')this.value ='<?php echo htmlentities($efind); ?>'" value="<?php echo htmlentities($efind); ?>" />

,

0

Hakan, ajax (, , ), php + apache/nginx , , , , . , cookie , , cookie Ajax. , . nginx memcache php + apc + apache + mod_sitespeed

0

All Articles