help in cookies

Results 1 to 9 of 9

Thread: help in cookies

  1. #1
    sunny Guest

    Default help in cookies

    I have four pages. When a user comes in he has to come to first page where he selects state, second page he selects district, third page he selects school and then he comes to login page.<BR> I want the cookies to remember which state, which district and which school this guys is going to use so that he directly goes to the fourth page which is the login page.<BR> How to do it ?? I need some help with code. I have these three variables as session which i get on respective pages.<BR>could someone please tell me how to use cookies here ???

  2. #2
    trish Guest

    Default RE: help in cookies

    Assuming "state" is the name of one of your cookies, and the value you&#039re giving it will be the request object (eg request.querystring [or request.from]("state"), the code for storing cookies is:<BR><BR>&#060;%response.cookies("state")=reques t.querystring("state")%&#062;<BR><BR>The code for retrieving & displaying this value would be:<BR><BR>&#060;%=request.cookies("state")%&#062; <BR><BR>Hope this helps as a starter.

  3. #3
    Johnny Lin Guest

    Default RE: help in cookies

    This is if you have a cookie called &#039SavedPreference&#039. You can then save each value in the cookie separately.<BR>This will save your &#039state&#039 value in your cookie.<BR>&#060;%<BR> Response.Cookies("SavedPreference")("state") = Request.Form("state")<BR>%&#062;<BR><BR>To access your cookie<BR>&#060;%<BR> Request.Cookies("SavedPreference")("state")<BR>%&# 062;

  4. #4
    sunny Guest

    Default second step now ???

    Thanks trish....<BR><BR>So I should do it like this:<BR><BR>1. &#060;%response.cookies("state")=request.querystri ng("state")<BR>2. response.cookies("district")=request.querystring(" dist")<BR>3. response.cookies("school")=request.querystring("sc hl") %&#062;<BR> so i get all these three variable on the third page. now how would i give the path to the page i have to send the user ??<BR>now to retrieve value...<BR>&#060;% stateC = request.cookies("state")<BR> districtC =request.cookies("state")<BR> schoolC = request.cookies("state") %&#062;<BR> IS this correct ????<BR>Now to suggest the path, where should (which page) i give the path where i need to send it and what the syntax of sending it.<BR><BR><BR><BR>

  5. #5
    Suuny Guest

    Default Thanks Johhny

    Thanks Johhny,<BR>To access the cookiedo u mean to put it in a variable like this.<BR>&#060;%<BR>stateC = Request.Cookies("SavedPreference")("state")<BR>%&# 062;<BR>or some thing else ??<BR>Also if you can look at the other question i asked??on my reply to trish....please<BR><BR>Thanks<BR>

  6. #6
    trish Guest

    Default RE: second step now ???

    not too sure about what you mean...<BR><BR>you&#039re correct about the method of retrieving the cookie value, but you need to explain in clearer detail it is you&#039re trying to do.

  7. #7
    Sunny Guest

    Default RE: second step now ???

    Hey trish..thanks..<BR>I will try to explain myself ...<BR>I want the fourth page to be displayed directly. So, Ok i get the value from cookies when a user for the first time goes on the page with some values. Now how to use these variables to open the fourth page directly when he types the website address next time, instead repeating the same routine.<BR><BR>does this makes clear what i want ???<BR>may be i am trying to do it wrong way, but this is what i want ??<BR>i can still explain more about it if you want to ..??<BR>thanks

  8. #8
    trish Guest

    Default RE: second step now ???

    I think I have an idea of what you&#039re trying to do but am not too sure about the solution.<BR><BR>When your users log on to your homepage (eg http://yourURL/default.asp), you&#039ll have to use the RESPONSE.REDIRECT method to open another page depending on the cookies that are stored on the computer.<BR><BR>response.redirect("antoherpage?st ate=" & request.cookies("state"))... etc. please note that each value in the query string needs to be separate by the ampersand(&)<BR><BR>Also, in order for the redirection to work correctly, you have to make sure that the cookies are not empty....

  9. #9
    Johnny Lin Guest

    Default RE: Thanks Johhny

    Yes you can retrieve your cookie like that.<BR>From what I am reading, looks like you want the first page to see if there is a cookie value, and if there is, then it goes to the 4th page.<BR><BR>I would try checking to see if the cookie has a value and do some kind of redirect to the 4th page if it does:<BR>&#060;%<BR> If Request.Cookies("SavedPreferences").HasKeys<BR> Response.Redirect("fourthpage.asp")<BR> Else<BR>%&#062;<BR><BR>Body of the first page goes here.<BR><BR>&#060;%<BR> End if<BR>%&#062;<BR><BR>This is what I can think of right now. There&#039s probably another way. Look for information on Redirecting and Detecting Cookies and that should do the trick. Don&#039t forget to set your Buffer to True or else the Redirect won&#039t work.<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts