如何将string []数组值分配给cookie [英] How to assign a string[] array values to a cookie

查看:132
本文介绍了如何将string []数组值分配给cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字符串数组,它由数据库填充,我想将其[string [] array]值分配给cookie.请粘贴一些代码.
我的代码是-

I have a string array and it is filling by database and i want to assign its[string[] array] values to a cookie. Please Paste some code.
My code is --

Array ar_Driver = (Array)fn.Arr_Driver();
HttpCookie Driver = new HttpCookie("Driver");
Driver.Value = Convert.ToString(ar_Driver);
Driver.Expires = DateTime.Now.AddHours(1);
Response.Cookies.Add(Driver);

推荐答案

Cookie仅保存一个字符串:因此,您需要将字符串数组转换为单个字符串,然后再次返回.
Cookies only hold a string: so you would need to convert your string array to a single string and back again.


这篇关于如何将string []数组值分配给cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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