c# - Cookie with different path value not present in Request.Cookies -


i'm creating mvc version of old asp web app , need reuse existing cookies users don't have reconfigure settings in mvc version. of cookies have path value of / others have path value of /scripts. ones /scripts path value not contained in request.cookies.

can know how access , update /scripts cookies in controller? i'm new mvc way.

ideally i'd server side solution if not possible client side solution should workable.

thanks

server side code , set cookies :         public void setcookie(string key, string value, timespan expires)         {             var encodedcookie = new httpcookie(key, value);              encodedcookie.httponly = true;              if (httpcontext.current.request.cookies[key] != null)             {                 var cookieold = httpcontext.current.request.cookies[key];                 cookieold.expires = datetime.now.add(expires);                 cookieold.value = encodedcookie.value;                 httpcontext.current.response.cookies.add(cookieold);             }             else             {                 encodedcookie.expires = datetime.now.add(expires);                 httpcontext.current.response.cookies.add(encodedcookie);             }         }          public string getcookie(string key)         {             string value = string.empty;             httpcookie cookie = httpcontext.current.request.cookies[key];              if (cookie != null)             {                 // security purpose, need encrypt value.                 httpcookie decodedcookie = cookie;                 value = decodedcookie.value;             }             return value;         }     client side code , set cookies      function setcookie(cname, cvalue, exdays) {         var d = new date();         d.settime(d.gettime() + (exdays * 24 * 60 * 60 * 1000));         var expires = "expires=" + d.togmtstring();         document.cookie = cname + "=" + cvalue + "; " + expires;     }      function getcookie(cname) {         var name = cname + "=";         var ca = document.cookie.split(';');         (var = 0; < ca.length; i++) {             var c = ca[i];             while (c.charat(0) == ' ') c = c.substring(1);             if (c.indexof(name) != -1) {                 return c.substring(name.length, c.length);             }         }         return "";     } 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -