Davood
Davood

Reputation: 5635

how can i read cookie value that written by jquery?

i created a cookie by jquery version: jquery-1.10.2 by this syntax

$.cookie('coockiename', 'abc');

on my client after that user click a link and redirect to an action but in this action i can not read that cookie in my request by this syntax

Request.Cookies["coockiename"]

and it's null and unavailable.

i think created cookie is not written in my request is it true or not and how can i handle it? (my sample application developed in mvc3 razor)

Upvotes: 1

Views: 1324

Answers (1)

Rory McCrossan
Rory McCrossan

Reputation: 337560

You also need to set the path of the cookie to the root of the site to ensure it can be read in C#:

$.cookie('coockiename', 'abc', { path : '/' });

Upvotes: 2

Related Questions