473,624 Members | 2,135 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Give Request.Cookies and Response.Cookie s is there any reason to use another method to use cookies?

Given Request.Cookies and Response.Cookie s in asp.net is there any reason to
ever use javascript or any other method to use cookies?

Thanks
Sep 18 '08 #1
10 1659
eg :if you want to save the layout of the ajax page.
"_Who" <Ca**********@r oadrunner.comд ÈëÏûÏ¢
news:ey******** *****@TK2MSFTNG P02.phx.gbl...
Given Request.Cookies and Response.Cookie s in asp.net is there any reason
to ever use javascript or any other method to use cookies?

Thanks

Sep 18 '08 #2
For example if you have to set them client side... Not sure what is the goal
of this question though ? IMO in most cases you'll use server side code if
what you want is a confirmation that what you does is quite standard...

--
Patrice

"_Who" <Ca**********@r oadrunner.coma écrit dans le message de groupe de
discussion : ey************* @TK2MSFTNGP02.p hx.gbl...
Given Request.Cookies and Response.Cookie s in asp.net is there any reason
to ever use javascript or any other method to use cookies?

Thanks

Sep 18 '08 #3
There is much JavaScript cookie code on the Internet and in books, that
shows how to write, read, and take apart what is read.
I have some saved. I was wondering if there is any reason for me to save
that.

Also, I work alone so it would be valuable to hear that using
Request.Cookies and Response.Cookie s is a good approach not withstanding all
the code that uses document.cookie .

It's confusing. For example your statement: "For example if you have to set
them client side... "
Is there some reason to do that?

In fact, I'm looking at a 75-line code that is used to display the number of
visits by the person to the site. It uses document.cookie and JavaScript. Is
that the way you'd do it?

Thanks for helping
"Patrice" <http://www.chez.com/scribe/wrote in message
news:0A******** *************** ***********@mic rosoft.com...
For example if you have to set them client side... Not sure what is the
goal of this question though ? IMO in most cases you'll use server side
code if what you want is a confirmation that what you does is quite
standard...

--
Patrice

"_Who" <Ca**********@r oadrunner.coma écrit dans le message de groupe de
discussion : ey************* @TK2MSFTNGP02.p hx.gbl...
>Given Request.Cookies and Response.Cookie s in asp.net is there any reason
to ever use javascript or any other method to use cookies?

Thanks


Sep 18 '08 #4

<ch*****@126.co mwrote in message
news:59******** *************** ***********@mic rosoft.com...
eg :if you want to save the layout of the ajax page.
I don't think I'm there yet. I mean I haven't gotten to ajax yet.

Thanks

>

"_Who" <Ca**********@r oadrunner.comд ÈëÏûÏ¢
news:ey******** *****@TK2MSFTNG P02.phx.gbl...
>Given Request.Cookies and Response.Cookie s in asp.net is there any reason
to ever use javascript or any other method to use cookies?

Thanks


Sep 18 '08 #5
IMO don't save something you find easily on the web. Knowing you can is
enough and you'll have no problem to find this again when needed...

You have likely more than this cookie to produce an approximate number of
current users on your site and no I wouldn't do this way (you have a cookie
though for your ASP.NET session).

I remember to have done this at least one time (setting the cookie client
side) but I don't remember what was the purpose.

I would do things the other way round. Instead of asking why you would do
something in a particular way, tell rather what you are trying to do and
someone will likely give - if not the mythical "best way" - at least a
possible logical way to do that...

Do you want to display on your page an approximate number of users currently
visiting the site ?

--
Patrice

"_Who" <Ca**********@r oadrunner.coma écrit dans le message de groupe de
discussion : Of************* *@TK2MSFTNGP06. phx.gbl...
There is much JavaScript cookie code on the Internet and in books, that
shows how to write, read, and take apart what is read.
I have some saved. I was wondering if there is any reason for me to save
that.

Also, I work alone so it would be valuable to hear that using
Request.Cookies and Response.Cookie s is a good approach not withstanding
all the code that uses document.cookie .

It's confusing. For example your statement: "For example if you have to
set them client side... "
Is there some reason to do that?

In fact, I'm looking at a 75-line code that is used to display the number
of visits by the person to the site. It uses document.cookie and
JavaScript. Is that the way you'd do it?

Thanks for helping


Sep 18 '08 #6
The answer your last question is yes.

But I find mostly cookie code on the internet uses JavaScript and from your
reply I now know that with ASP.NET that is not the way to go. For that I
thank you.
"Patrice" <http://www.chez.com/scribe/wrote in message
news:F5******** *************** ***********@mic rosoft.com...
IMO don't save something you find easily on the web. Knowing you can is
enough and you'll have no problem to find this again when needed...

You have likely more than this cookie to produce an approximate number of
current users on your site and no I wouldn't do this way (you have a
cookie though for your ASP.NET session).

I remember to have done this at least one time (setting the cookie client
side) but I don't remember what was the purpose.

I would do things the other way round. Instead of asking why you would do
something in a particular way, tell rather what you are trying to do and
someone will likely give - if not the mythical "best way" - at least a
possible logical way to do that...

Do you want to display on your page an approximate number of users
currently visiting the site ?

--
Patrice

"_Who" <Ca**********@r oadrunner.coma écrit dans le message de groupe de
discussion : Of************* *@TK2MSFTNGP06. phx.gbl...
>There is much JavaScript cookie code on the Internet and in books, that
shows how to write, read, and take apart what is read.
I have some saved. I was wondering if there is any reason for me to save
that.

Also, I work alone so it would be valuable to hear that using
Request.Cookie s and Response.Cookie s is a good approach not withstanding
all the code that uses document.cookie .

It's confusing. For example your statement: "For example if you have to
set them client side... "
Is there some reason to do that?

In fact, I'm looking at a 75-line code that is used to display the number
of visits by the person to the site. It uses document.cookie and
JavaScript. Is that the way you'd do it?

Thanks for helping



Sep 18 '08 #7
"_Who" <Ca**********@r oadrunner.comwr ote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
The answer your last question is yes.

But I find mostly cookie code on the internet uses JavaScript and from
your reply I now know that with ASP.NET that is not the way to go. For
that I thank you.
I'm not sure what its you are seeing. It is possible for cookies to be used
by both client and server. You use Javascript clientside to read and set
cookie info, you use Response.Cookie s to read cookies server side and
Resquest.Cookie s to set them. Personally I rarely do the clientside thing
its usually server side.

--
Anthony Jones - MVP ASP/ASP.NET

Sep 18 '08 #8
A basic approach is to use the session start and end event (see
global.asax). Increase an application variable when a session starts and
decrease the application variable when the session ends.

That said the end event of a session doesn't happen in some cases (when
using the SQL Server provider) or is/was not known to be terribly reliable
so my personal approach would be :
- to keep track in an application variable of each session I heard about
including a timestamp
- counting recently used session (whatever criteria you want as you have a
timestamp) gives the number of users
- you can remove old sessions records from the list and you don't care about
session events happening or not

In all cases this is just indicative as http is stateless and you don't know
immediately when a user closes his browser. Some are doing a server side
call to close the session from a client side event but I never found it was
worth the trouble to go against http nature.

You should find lot of resources about this on Google (especially #1 and #3,
not sure about #2). In all cases, isolete this code so that you'll be able
to change the method you are suing at will without changing anyhting in the
rest of your code.

--
Patrice

"_Who" <Ca**********@r oadrunner.coma écrit dans le message de groupe de
discussion : #K************* *@TK2MSFTNGP04. phx.gbl...
The answer your last question is yes.

But I find mostly cookie code on the internet uses JavaScript and from
your reply I now know that with ASP.NET that is not the way to go. For
that I thank you.
"Patrice" <http://www.chez.com/scribe/wrote in message
news:F5******** *************** ***********@mic rosoft.com...
>IMO don't save something you find easily on the web. Knowing you can is
enough and you'll have no problem to find this again when needed...

You have likely more than this cookie to produce an approximate number of
current users on your site and no I wouldn't do this way (you have a
cookie though for your ASP.NET session).

I remember to have done this at least one time (setting the cookie client
side) but I don't remember what was the purpose.

I would do things the other way round. Instead of asking why you would do
something in a particular way, tell rather what you are trying to do and
someone will likely give - if not the mythical "best way" - at least a
possible logical way to do that...

Do you want to display on your page an approximate number of users
currently visiting the site ?

--
Patrice

"_Who" <Ca**********@r oadrunner.coma écrit dans le message de groupe de
discussion : Of************* *@TK2MSFTNGP06. phx.gbl...
>>There is much JavaScript cookie code on the Internet and in books, that
shows how to write, read, and take apart what is read.
I have some saved. I was wondering if there is any reason for me to save
that.

Also, I work alone so it would be valuable to hear that using
Request.Cooki es and Response.Cookie s is a good approach not withstanding
all the code that uses document.cookie .

It's confusing. For example your statement: "For example if you have to
set them client side... "
Is there some reason to do that?

In fact, I'm looking at a 75-line code that is used to display the
number of visits by the person to the site. It uses document.cookie and
JavaScript. Is that the way you'd do it?

Thanks for helping



Sep 18 '08 #9
I'm probably finding code for users not doing ASP.NET

Thanks

"Anthony Jones" <An***********@ yadayadayada.co mwrote in message
news:uj******** ******@TK2MSFTN GP03.phx.gbl...
"_Who" <Ca**********@r oadrunner.comwr ote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>The answer your last question is yes.

But I find mostly cookie code on the internet uses JavaScript and from
your reply I now know that with ASP.NET that is not the way to go. For
that I thank you.

I'm not sure what its you are seeing. It is possible for cookies to be
used by both client and server. You use Javascript clientside to read and
set cookie info, you use Response.Cookie s to read cookies server side and
Resquest.Cookie s to set them. Personally I rarely do the clientside
thing its usually server side.

--
Anthony Jones - MVP ASP/ASP.NET

Sep 18 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2416
by: Drew | last post by:
I have been trying to figure out why I am getting this message... I have an application that is 20 different ASP pages that works in sequential order (step1, step2, step3...). After each step the app writes the entered text to a cookie. This feature is so that if there is a problem, we can still retrieve the data. This Bad Request error has something to do with the cookie that is written to, because I can go all the way through the app...
1
1845
by: Bhupesh Saini | last post by:
I am trying to call a ASPX page using HttpWebRequest class and pass cookie information to it. My ASPX pages gets called just fine, however none of the request cookies are available to the ASPX page. What do I need to do to have the cookies sent along with the request Below is the code snippet from the function I an using I am using to achieve the above. EVerything works except that I do not see any cookies in request object for the ASPX page...
4
3151
by: James Johnson | last post by:
Dear C#Dex, I am trying to automate a POST to a web page that clicks a button. I have been able to hit a target web page and run the web page. However, the button on the page does not click. I can set the target web page to change to a new URL when I hit it, and that works, but I cannot get the button to click based on my POST command. Is there some secret to clicking the button? I have a button named btnGo and I set the value of...
1
4198
by: Ravi | last post by:
Hi , i am trying to pass the same session Id to all the webrequest, but sometimes the response.cookies returns zero and sometimes one. is this to do something with cookies expire. In this sample code the line Console.WriteLine("cookies1 count : " + firstResponse.Count.ToString()); and Console.WriteLine("second Cookie : " + secondResponse.Cookies.Count.ToString());
1
11425
by: Alex Nitulescu | last post by:
I have the following very simple colde (while learning about cookies and session state): Private Sub cmdAddCookie_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddCookie.Click Dim strCookieName As String Dim objRandom As New Random() strCookieName = "MyCookie" & objRandom.Next(Integer.MaxValue).ToString
5
5291
by: Miljana | last post by:
Hi, I have one problem with cookies in ASP.NET application. It seems that I can not retreive cookie from Request.Cookies collection. I put cookie in Response.Cookies collection, and after page post back, when I try to retreive it from Request.Cookies collection, it appears that it does not exists. This problem does not occur on several developing machines we use for developing application, but occurs in another environment (another...
3
2454
by: Arpan | last post by:
An ASPX page has the following code: Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) If Not (IsNothing(Request.Cookies("AuthCookie"))) Then Response.Write(Request.Cookies("AuthCookie").Value) Else Response.Write(Cookie 'AuthCookie' Doesn't Exist!) End If End Sub
3
4991
by: dihola | last post by:
Hi, I have a website running in IIS7 and it seems to be creating a new session for every request I make. The values I store in Session are lost with every request. This is the forms bit in my web.config: <authentication mode="Forms"> <forms name=".ReMaCRM" loginUrl="~/Login.aspx" defaultUrl="~/Default.aspx" cookieless="AutoDetect" domain="" timeout="10" protection="All" /> </authentication>
6
1377
by: jake | last post by:
I think I may why this is happening but I am a little fuzzy as to what the solution should be as I am somewhat new to all of this. My simplified code that generates the error is: public static string getCartCookieValue() { if (Request.Cookies != null) {
0
8234
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8172
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
7158
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5563
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4079
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2605
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1784
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1482
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.