如何在cookie中存储图像 [英] How to store image in cookies

查看:91
本文介绍了如何在cookie中存储图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个eccomerce网站,我在商店里使用cookie存储数据。

我很容易存储字符串变量但存储图像时遇到问题。



我尝试了什么:



i am making an eccomerce website where i have store data in cart using cookie.
I am easily store string variable but problem facing when storing image.

What I have tried:

HttpCookie userInfo = new HttpCookie("userInfo");
userInfo["image"] = Image1.ImageUrl;

userInfo["cakename"] = cakename.Text;
userInfo.Expires.Add(new TimeSpan(0, 1, 0));
Response.Cookies.Add(userInfo);
ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Successfully Added to cart');", true);

推荐答案

查看对此的回复发布 [ ^ ]



基本上 - 不存储图像本身,存储链接。一旦看到图片,浏览器应该对其进行缓存,以便减少额外开销。
See the responses to this post[^]

Basically - don't store the image itself, store a link to it. Once the picture has been seen once the browser should cache it so there is minimal extra overhead.


这篇关于如何在cookie中存储图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆