HELP,<BR>I have a problem here, When a user comes to the site I check to see if they<BR>have cookie("UID") and if they dont I write a new one with the GUID as the<BR>value and redirect them with the Cookies Value appended to the end of the<BR>URL. BUT for some reason It doesnt write the cookies or something because it<BR>seems to make a new GUID every time they visit. Below is my code. Can anyone<BR>see whats going on? You can visit the site that this works on at<BR>http://www.americangolfclassics.com.<BR>Thanks<BR>john<BR><BR>'Global.asax.vb<BR>Imports System<BR>Imports System.IO<BR>Imports System.Web<BR>Imports hi.redir<BR>imports Microsoft.VisualBasic<BR>imports System.Diagnostics<BR><BR>Public Class Global<BR> Inherits System.Web.HttpApplication<BR><BR>#Region " Component Designer Generated Code "<BR><BR> Public Sub New()<BR> MyBase.New()<BR><BR> 'This call is required by the Component Designer.<BR> InitializeComponent()<BR><BR> 'Add any initialization after the InitializeComponent() call<BR><BR> End Sub<BR><BR> 'Required by the Component Designer<BR> Private components As System.ComponentModel.IContainer<BR><BR> 'NOTE: The following procedure is required by the Component Designer<BR> 'It can be modified using the Component Designer.<BR> 'Do not modify it using the code editor.<BR> <System.Diagnostics.DebuggerStepThrough()> Private Sub<BR>InitializeComponent()<BR> components = New System.ComponentModel.Container()<BR> End Sub<BR><BR>#End Region<BR><BR> Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)<BR> ' Fires when the application is started<BR> End Sub<BR><BR> Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)<BR> Session.Timeout = 15<BR> Dim host As String = Request.ServerVariables("SERVER_NAME").ToLower<BR> Dim ServerDir As String = ""<BR> Dim PageURL As String = Request.ServerVariables("URL")<BR><BR> 'Dim obj As redir.Go_to<BR> 'Call obj.newhost(host)<BR> Dim uGUID As String = ""<BR><BR> If (GetCookie("UID") Is Nothing) Then<BR> Dim cookie As New HttpCookie("UID")<BR> uGUID = System.Guid.NewGuid().ToString.Replace("-", Nothing)<BR> SetCookie("UID", uGUID, 30)<BR> Else<BR> uGUID = Nothing<BR> uGUID = GetCookie("UID")<BR> End If<BR><BR> Select Case host<BR> Case "RemovedforThisemail.com"<BR> ServerDir = checkURl(PageURL, "/RemovedforThisemail")<BR> Case "RemovedforThisemail.com"<BR> ServerDir = checkURl(PageURL, "RemovedforThisemail")<BR> Case "RemovedforThisemail.com"<BR> ServerDir = checkURl(PageURL, "/RemovedforThisemail")<BR> Case "www.RemovedforThisemail.com"<BR> ServerDir = checkURl(PageURL, "/RemovedforThisemail")<BR> Case "RemovedforThisemail.com"<BR> ServerDir = checkURl(PageURL, "/RemovedforThisemail")<BR> Case "www.americangolfclassics.com"<BR> ServerDir = checkURl(PageURL, "/c_AmGolf/Home/" + uGUID +<BR>".hi")<BR> Case "americangolfclassics.com"<BR> ServerDir = checkURl(PageURL, "/c_AmGolf/Home/" + uGUID +<BR>".hi")<BR><BR> Case "test.RemovedforThisemail.com"<BR> ServerDir = checkURl(PageURL, "/c_test/Home/" + uGUID +<BR>".hi")<BR> Case "RemovedforThisemail.org"<BR> ServerDir = checkURl(PageURL, "/RemovedforThisemail")<BR> Case "www.RemovedforThisemail.org"<BR> ServerDir = checkURl(PageURL, "/RemovedforThisemail")<BR> Case "RemovedforThisemail.com"<BR> ServerDir = checkURl(PageURL, "/RemovedforThisemail")<BR> Case "www.RemovedforThisemail.com"<BR> ServerDir = checkURl(PageURL, "/RemovedforThisemail")<BR> Case "RemovedforThisemail.com"<BR> ServerDir = checkURl(PageURL, "/RemovedforThisemail")<BR> Case "www.RemovedforThisemail.com"<BR> ServerDir = checkURl(PageURL, "/RemovedforThisemail")<BR> Case "RemovedforThisemaile.com"<BR> ServerDir = checkURl(PageURL, "/RemovedforThisemail")<BR> Case Else<BR> ServerDir = checkURl(PageURL, "/iRemovedforThisemail")<BR> End Select<BR><BR> Response.Redirect(ServerDir)<BR> End Sub<BR><BR> Sub Application_BeginRequest(ByVal sender As Object, ByVal e As<BR>EventArgs)<BR> ' Fires at the beginning of each request<BR> End Sub<BR><BR> Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As<BR>EventArgs)<BR> ' Fires upon attempting to authenticate the use<BR> End Sub<BR><BR> Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)<BR><BR> Dim strError As String = "Error in: " + Request.Path +<BR>ControlChars.Lf + "Url: " + Request.RawUrl + ControlChars.Lf +<BR>ControlChars.Lf<BR><BR> ' Get the exception object for the last error message that occured.<BR> Dim ErrorInfo As Exception =<BR>Server.GetLastError().GetBaseException()<BR> strError += "Error Message: " + ErrorInfo.Message + ControlChars.Lf<BR>+ "Error Source: " + ErrorInfo.Source + ControlChars.Lf + "Target Site: " +<BR>ErrorInfo.TargetSite.ToString() + ControlChars.Lf + "QueryString Data:" +<BR>ControlChars.Lf + "-----------------" + ControlChars.Lf<BR><BR> 'strError += "Error Target Site: " + ErrorInfo.TargetSite +<BR>ControlChars.Lf<BR><BR> ' Gathering QueryString information<BR> Dim i As Integer<BR> For i = 0 To Context.Request.QueryString.Count - 1<BR> strError += Context.Request.QueryString.Keys(i) + ":" +<BR>ControlChars.Tab + ControlChars.Tab + Context.Request.QueryString(i) +<BR>ControlChars.Lf<BR> Next i<BR> strError += ControlChars.Lf + "Post Data:" + ControlChars.Lf +<BR>"----------" + ControlChars.Lf<BR><BR> ' Gathering Post Data information<BR><BR> For i = 0 To Context.Request.Form.Count - 1<BR> strError += Context.Request.Form.Keys(i) + ":" +<BR>ControlChars.Tab + ControlChars.Tab + Context.Request.Form(i) +<BR>ControlChars.Lf<BR> Next i<BR> strError += ControlChars.Lf<BR><BR> If User.Identity.IsAuthenticated Then<BR> strError += "User:" + ControlChars.Tab + ControlChars.Tab +<BR>User.Identity.Name + ControlChars.Lf + ControlChars.Lf<BR> End If<BR> strError += "Exception Stack Trace:" + ControlChars.Lf +<BR>"----------------------" + ControlChars.Lf +<BR>Server.GetLastError().StackTrace + ControlChars.Lf + ControlChars.Lf +<BR>"Server Variables:" + ControlChars.Lf + "-----------------" +<BR>ControlChars.Lf<BR><BR> ' Gathering Server Variables information<BR> For i = 0 To Context.Request.ServerVariables.Count - 1<BR> strError += Context.Request.ServerVariables.Keys(i) + ":" +<BR>ControlChars.Tab + ControlChars.Tab + Context.Request.ServerVariables(i) +<BR>ControlChars.Lf<BR> Next i<BR> strError += ControlChars.Lf<BR><BR> ' Sending error message to administration via e-mail<BR> System.Web.Mail.SmtpMail.Send("[email protected]",<BR>"[email protected]", "error has occured", strError)<BR> End Sub<BR><BR> Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)<BR> ' Fires when the session ends<BR> End Sub<BR><BR> Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)<BR> ' Fires when the application ends<BR> End Sub<BR><BR> Public Function checkURl(ByVal url As String, ByVal ServerDir As String)<BR> If Not (url Is Nothing) Then<BR> If (url.IndexOf(ServerDir) > -1) Then<BR> Return url<BR> Else<BR> Return ServerDir<BR> End If<BR> Else<BR> Return ServerDir<BR> End If<BR> End Function<BR> Dim cookyexpires As String = ""<BR><BR> Public Function SetCookie(ByVal cookiename As String, ByVal cookievalue<BR>As String, ByVal iDaysToExpire As Integer) As Boolean<BR> Try<BR> Dim objCookie As New HttpCookie(cookiename)<BR> Response.Cookies.Clear()<BR> Response.Cookies.Add(objCookie)<BR> objCookie.Values.Add(cookiename, cookievalue)<BR> Dim dtExpiry As DateTime = DateTime.Now.AddDays(iDaysToExpire)<BR> Response.Cookies(cookiename).Expires = dtExpiry<BR> Catch e As Exception<BR> Return False<BR> End Try<BR> Return True<BR> End Function 'SetCookie<BR><BR> Public Function GetCookie(ByVal cookiename As String) As String<BR> Dim cookyval As String = ""<BR> Try<BR> cookyval = Request.Cookies(cookiename).Value<BR> Catch e As Exception<BR> cookyval = ""<BR> End Try<BR> Return cookyval<BR> End Function 'GetCookie<BR><BR><BR>End Class<BR><BR>