-
31 Jul 2007 2:52 AM #1
Can i read cookie?
Can i read cookie?
I want to get a cookie value... is possible?
Thanks a lot
-
31 Jul 2007 2:54 AM #2
just only if it was you who set the cookie, you can't read the client's cooky that was set by someone else (i.e. ebay.com).
-
31 Jul 2007 5:14 AM #3
-
31 Jul 2007 5:16 AM #4
I try this:
but userId is always -1...Code:var cp = new Ext.state.CookieProvider(); var userId = cp.get('bbuserid', '-1');
-
31 Jul 2007 5:21 AM #5
The cookie was set by this asp.net code :
The next time I pass this code, I can read the cookie correctly, and it give me the correct value.Code:Dim idUser As String If Request.Cookies("bbuserid") IsNot Nothing ThenidUser = Request.Cookies("bbuserid").ValueElseidUser = Request.QueryString("bbuserid") If idUser IsNot Nothing AndAlso idUser.Trim.Length > 0 ThenEnd IfResponse.Cookies.Add(New HttpCookie("bbuserid", idUser))End If
But, if I read the same cookie with CookieProvider, it give me nothing.
The Asp.Net and JavaScript code is in the same web server and in the same directory application.
-
31 Jul 2007 7:19 AM #6
Sorry if I miss lead you. CookieProvider isn't intended for setting/getting cookies - it's for storing state in cookies. But it has functionality of reading/writing cookies so you can take a look at the source.
Values are stored with "ys-" prefix...
-
31 Jul 2007 7:33 AM #7
Thanks for reply, but the problem is that I want read a cookie from extjs ... Because I've set in this cookie, the iduser. The id user was set by a .Net application. This is the problem...
-
31 Jul 2007 7:37 AM #8
I solve the problem with this 3 function:
Thanks a lotCode:function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { createCookie(name,"",-1); }
BabSevenSix
-
29 Jan 2010 12:05 AM #9
Cookies in EXTJS
Cookies in EXTJS
First u set your value using a key...then fetch the value in any page using that Key...
For setting cookies
new Ext.util.Cookies.set("loginUser", 'utpal');
Here loginUser is the key and 'utpal' is the value.
now in any page where you need this value use
Ext.util.Cookies.get("loginUser");
If someone find any more good way then please write in this forum.


Reply With Quote