Solved

cookie overwrite

Posted on 2004-08-16
9
442 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
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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

867 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

17 Experts available now in Live!

Get 1:1 Help Now