'****************************************************************************************************************
'* Id Application modified by:   Date(MM/dd/yyyy)   Description													*
'* -- ------------------------   --------           -------------------------------------------	    			*
'* 01 Raśl Callupe - PACNET      03/10/2006         Creation of the CookieManager class used in order to        *
'*                                                  manage the application cookie stored inside clients' pc     *
'****************************************************************************************************************

Public Class CookieManager

    'Start, id: 01
    Public Shared Function GetLolfarCookie(ByRef req As HttpRequest, ByRef res As HttpResponse) As HttpCookie
        Dim cookie As HttpCookie = req.Cookies.Get(Constants.CONST_TYPE_COOKIE)

        If cookie Is Nothing Then
            cookie = New HttpCookie(Constants.CONST_TYPE_COOKIE)
            cookie.Expires = DateTime.Now.AddYears(1)
            res.Cookies.Add(cookie)
        End If

        Return cookie

    End Function
    'End, id: 01

    'Start, id: 01
    Public Shared Function GetCookieValue(ByRef req As HttpRequest, _
                                    ByRef res As HttpResponse, _
                                    ByVal cookieKey As String) As String

        Dim cookie As HttpCookie = GetLolfarCookie(req, res)

        If Not cookie Is Nothing Then
            Return cookie.Values.Get(cookieKey)
        Else
            Return Nothing
        End If

    End Function
    'End, id: 01

End Class
