Solved

cookie overwrite

Posted on 2004-08-16
9
447 Views
Last Modified: 2008-02-01

I'm trying this but the cookie keeps the same value, how can i overwirte it?

Response.Cookies("ID").Value = ID

OR


'Dim c As New System.Web.HttpCookie("ID", strID)
'c.Expires = Now.AddDays(2)
'Response.Cookies.Add(c)


Request.Cookies("ID").Value  -- old value ...
0
Comment
Question by:testn1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11815566
0
 

Author Comment

by:testn1
ID: 11815570
or   Response.Cookies.Item("ID").Value = ID   .. and nothing..
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 500 total points
ID: 11815602
btw I didnt think C# would be a problem as I see you in the C# TA let me know if you need VB.NET
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

Author Comment

by:testn1
ID: 11815631
hi gregory,

this time is vb .. it works fine on c#,  but can't overwrite/make it work on vb .net
0
 

Author Comment

by:testn1
ID: 11815684
looks like the problem is overwriting the cookie
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11815717
Public Class WebForm1
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub ChangeCookieInfo()
        If Request.Cookies.Item("Count") Is Nothing Then
            Dim cookie As HttpCookie = New HttpCookie("Count")
            cookie.Value = "0"
            cookie.Expires = Now.AddDays(100)
            Response.AppendCookie(cookie)
        Else
            Response.Cookies("Count").Value = CType(Request.Cookies("Count").Value, Integer) + 1
        End If
    End Sub

    Private Sub ShowCookieInfo()
        Response.Write("Old value = " + Request.Cookies("Count").Value)
    End Sub

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ChangeCookieInfo()
        ShowCookieInfo()
    End Sub

End Class
0
 

Author Comment

by:testn1
ID: 11819952
it's interesting...

i run this   If Request.Cookies.Item("Count") Is Nothing Then
            Dim cookie As HttpCookie = New HttpCookie("Count")
            cookie.Value = "0"
            cookie.Expires = Now.AddDays(100)
            Response.AppendCookie(cookie)
        Else
            Response.Cookies("Count").Value = CType(Request.Cookies("Count").Value, Integer) + 1
        End If
and the cookie is nothing... but if i do   If Request.Cookies.Item("Count") on the immediate window, i  get all the OLD values, the new one does not get assigned..

0
 

Author Comment

by:testn1
ID: 11820477
definitely is not overwrtiting the cookie value..
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11820748
you mean that you set Response and Request still has the old value ? try looking at Response.Cookies.Item("Count") on the immediate window. It wont change until the next request.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question