--------------------------------Start Set Cookie from Javasript
///Get cookie
function getCookie(c_name) {
var i, x, y, ARRcookies = document.cookie.split(";");
for (i = 0; i < ARRcookies.length; i++) {
x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
x = x.replace(/^\s+\s+$/g, "");
if (x == c_name) {
return unescape(y);
}
}
}
///Set cookie
function setCookie(c_name, value, exdays) {
var exdate = new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
document.cookie = c_name + "=" + c_value;
}
///Check cookie
function checkCookie() {
var username = getCookie("username");
if (username != null && username != "") {
//alert("Welcome again " + username);
}
else {
username = prompt("Please enter your name:", "");
if (username != null && username != "") {
setCookie("username", username, 365);
}
}
}
--------------------------------End Set Cookie from Javasript
--------------------------------Start Get Cookie from Asp.Net
public string TapName
{
get
{
string tapname = string.Empty;
try
{
if (HttpContext.Current.Request.Cookies["TapName"] != null)
{
HttpCookie hc1 = HttpContext.Current.Request.Cookies["TapName"];
tapname = hc1.Value;
}
}
catch (Exception ex)
{
tapname = string.Empty;
}
return tapname;
}
}
///Get cookie
function getCookie(c_name) {
var i, x, y, ARRcookies = document.cookie.split(";");
for (i = 0; i < ARRcookies.length; i++) {
x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
x = x.replace(/^\s+\s+$/g, "");
if (x == c_name) {
return unescape(y);
}
}
}
///Set cookie
function setCookie(c_name, value, exdays) {
var exdate = new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
document.cookie = c_name + "=" + c_value;
}
///Check cookie
function checkCookie() {
var username = getCookie("username");
if (username != null && username != "") {
//alert("Welcome again " + username);
}
else {
username = prompt("Please enter your name:", "");
if (username != null && username != "") {
setCookie("username", username, 365);
}
}
}
--------------------------------End Set Cookie from Javasript
--------------------------------Start Get Cookie from Asp.Net
public string TapName
{
get
{
string tapname = string.Empty;
try
{
if (HttpContext.Current.Request.Cookies["TapName"] != null)
{
HttpCookie hc1 = HttpContext.Current.Request.Cookies["TapName"];
tapname = hc1.Value;
}
}
catch (Exception ex)
{
tapname = string.Empty;
}
return tapname;
}
}
--------------------------------Start Get Cookie from Asp.Net