javascript - Store data from image in a cookie -
i trying store image in cookie, don't know if best way keep registers user when refreshes page.
well, using ngcookies module that. received image server in base64 string format, contenttype , data , store in cookies:
$cookies.contenttype = value.image.contenttype; $cookies.data = value.image.data;
to make url this:
vm.url = "data:"+vm.value.image.contenttype+";base64,"+vm.value.image.data;
and url insert in page, using img html:
<img src={{ctrl.url}} style="width:200px;height:200px">
my problem is: when refreshed page, $cookies.contenttype remains, value.data doesn't stay stored in $cookies.data anymore. think value big store in cookie. using cookies correctly? there other way that?
i appreciate if can me.
using cookies client side storage considered less ideal. cookies automatically sent every request (if matches domain/path/security restrictions). if cookie storage limit handle can't imagine want send future request. localstorage , similar technologies developed in part avoid issue.
that said, http cookie spec stated cookie needed accommodate @ least 4096 bytes interpreted setting max size of approximately 4k. each browser handles bit differently , there plenty of places read on it.
Comments
Post a Comment