Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Cookie help


Message #1 by "Andy Ness" <aness@e...> on Wed, 29 Aug 2001 15:35:26 -0700
Hi,

I'm editing an ASP based survey page, and I'd like to add a cookie so that

it will only allow voting once per session per user. On submission of the

survey, it is supposed to run this subroutine:



	 <%Sub CountVote_OnSubmit

      	 CheckCookie=Request.Cookies.Item("survey")

	 if CheckCookie <> "" then

	  	 MsgBox("Please Vote Once Only")

		 Response.Redirect "/support/incidentgrid.asp"

	  else

	    Response.Cookies("survey")="survey"

	  end if

	  End Sub%>



So it checks if a cookie is there, if so it's supposed to redirect away from

the survey to the main page. Otherwise it sets the cookie and moves on,

which will prevent the user from voting again in the same session. What

happens in reality is that the user can click on submit as often as they

like and it does not block or redirect. Is the code correct? If so, maybe

I'm not calling the subroutine correctly on submission? Thanks in advance!

Andrew Ness



Message #2 by "Hema R." <hema.r@s...> on Thu, 30 Aug 2001 09:54:54 +0530
HI,

We cant have a msgbox on the server side

script firstly.

Then redirecting to the voting page will not be a problem.

if u remove the msgbox it should be fine



regards

hema



> -----Original Message-----

> From: Andy Ness [SMTP:aness@e...]

> Sent: 29 August Wednesday 2001 03:35 PM

> To: ASP Web HowTo

> Subject: [asp_web_howto] Cookie help

> 

> Hi,

> I'm editing an ASP based survey page, and I'd like to add a cookie so that

> it will only allow voting once per session per user. On submission of the

> survey, it is supposed to run this subroutine:

> 

>   <%Sub CountVote_OnSubmit

>         CheckCookie=Request.Cookies.Item("survey")

>   if CheckCookie <> "" then

>      MsgBox("Please Vote Once Only")

>    Response.Redirect "/support/incidentgrid.asp"

>    else

>      Response.Cookies("survey")="survey"

>    end if

>    End Sub%>

> 

> So it checks if a cookie is there, if so it's supposed to redirect away

> from

> the survey to the main page. Otherwise it sets the cookie and moves on,

> which will prevent the user from voting again in the same session. What

> happens in reality is that the user can click on submit as often as they

> like and it does not block or redirect. Is the code correct? If so, maybe

> I'm not calling the subroutine correctly on submission? Thanks in advance!

> Andrew Ness

> 

> 

> 
Message #3 by williams@s... on Thu, 30 Aug 2001 09:08:21 -0400
Try this:



<%Sub CountVote_OnSubmit

>         CheckCookie=Request.Cookies.Item("survey")

>   if CheckCookie <> "" then

>     Response.Write(vbCrLf & "<script language=VBScript" & vbCrLf)

     Response.Write("msgbox " & chr(34) & "Please Vote Once Only" & chr(34)

& vbCrLf)

     Response.Write("location.href=" & chr(34) & "/support/incidentgrid.asp

" & chr(34) & vbCrLf)

     Response.Write("</script>" & vbCrLf)

>    else

>      Response.Cookies("survey")="survey"

>    end if

>    End Sub%>



Wiliam





                                                                                                                       

                    "Hema R."                                                                                          

                    <hema.r@s...       To:     "ASP Web HowTo" <asp_web_howto@p...>                      

                    tware.com>               cc:                                                                       

                                             Subject:     [asp_web_howto] RE: Cookie help                              

                    08/30/2001 12:24                                                                                   

                    AM                                                                                                 

                    Please respond to                                                                                  

                    "ASP Web HowTo"                                                                                    

                                                                                                                       

                                                                                                                       









HI,

We cant have a msgbox on the server side

script firstly.

Then redirecting to the voting page will not be a problem.

if u remove the msgbox it should be fine



regards

hema



> -----Original Message-----

> From: Andy Ness [SMTP:aness@e...]

> Sent: 29 August Wednesday 2001 03:35 PM

> To: ASP Web HowTo

> Subject: [asp_web_howto] Cookie help

>

> Hi,

> I'm editing an ASP based survey page, and I'd like to add a cookie so

that

> it will only allow voting once per session per user. On submission of the

> survey, it is supposed to run this subroutine:

>

>   <%Sub CountVote_OnSubmit

>         CheckCookie=Request.Cookies.Item("survey")

>   if CheckCookie <> "" then

>      MsgBox("Please Vote Once Only")

>    Response.Redirect "/support/incidentgrid.asp"

>    else

>      Response.Cookies("survey")="survey"

>    end if

>    End Sub%>

>

> So it checks if a cookie is there, if so it's supposed to redirect away

> from

> the survey to the main page. Otherwise it sets the cookie and moves on,

> which will prevent the user from voting again in the same session. What

> happens in reality is that the user can click on submit as often as they

> like and it does not block or redirect. Is the code correct? If so, maybe

> I'm not calling the subroutine correctly on submission? Thanks in

advance!

> Andrew Ness

>

>

>


  Return to Index