jquery - localStorage or something else? -


i trying figure out best way store dynamically loaded html within div user's next visit.

i've read bit localstorage , possibly stringify info, however, not clear on implementation.

however, above said, here doing , accomplish.

i using code like:

$(function() {     $('.cordpass').click(function() {         var collection = $(this).find('span').load(this.href + ' #cords');         $('#summary').append( $(collection) );         return false;     }); }); 

this grabbing info page , adding div id of #summary. can done multiple objects on page (they on map). anyway, user can sort , kinds of stuff. works great needs. however, i'd save html within #summary next time user visits, html there.

what best way that? localstorage fit me, or misunderstanding use, , there way can store html next visit?

i think if data different each user store data in mysql database. if data coming page, need store link other page in database, , not data.

each user on page have different id in database, see data. assuming have kind of login procedure.

there isn't enough information give better answer @ moment.

ok add this. can of course use cookies store information on client side. of course cookies limited 4k each cookie. doesn't sound 4000 characters of text. said don't want using cookies lot of text, few links , variables fine store.

to set cookie this

setcookie($cookiename, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day 

this 30 days, possible make expiry date unlimited if wanted to. echo cookie this

echo $_cookie['cookiename']; 

you can store arrays in cookies too.

$test = array( 0 => array('bill', 'ted'), 1 => array('alpha', 'romeo'), 2 => array('chad', 'something') );  setcookie('names', $test); 

however if user logs in still suggest storing data in mysql database.

there other methods also. remember cookies live in browser opened them. if view page in 1 browser , change browsers cookie won't there. or if visit different machine.

if user has login doesn't matter machine visits page.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -