Solved

cookie overwrite

Posted on 2004-08-16
9
443 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
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
update textboxes with Streamreader 21 47
Close tabpage of custom control 9 34
C# Single Form 8 42
Get hold of longitude and latitude in iframe string 11 46
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

777 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