Solved

cookie overwrite

Posted on 2004-08-16
9
441 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
  • 5
  • 4
9 Comments
 
LVL 37

Expert Comment

by:gregoryyoung
Comment Utility
0
 

Author Comment

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

Accepted Solution

by:
gregoryyoung earned 500 total points
Comment Utility
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
 

Author Comment

by:testn1
Comment Utility
hi gregory,

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

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:testn1
Comment Utility
looks like the problem is overwriting the cookie
0
 
LVL 37

Expert Comment

by:gregoryyoung
Comment Utility
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
Comment Utility
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
Comment Utility
definitely is not overwrtiting the cookie value..
0
 
LVL 37

Expert Comment

by:gregoryyoung
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now