www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: Cookie Problem

  1. #1
    Join Date
    Apr 2004
    Location
    TX
    Posts
    94

    Cookie Problem

    I have a techincal support form. And when the user hits submit i want to give
    them a cookie. When they try to access this page again in a 24-48 hour time I
    want the page to identify the cookie and redirect them to an alternative
    page. Yet i am having a problem with the page.




    Here is my full code:





    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_findObj(n, d) { //v4.01
    var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
    }

    function MM_validateForm() { //v4.0
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
    if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
    if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
    } else if (test!='R') { num = parseFloat(val);
    if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
    if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
    min=test.substring(8,p); max=test.substring(p+1);
    if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
    }
    //-->
    </script>
    </head>

    <%
    Response.Expires = -1000 'Make sure the browser doesnt cache this page
    Response.Buffer = True 'enables our response.redirect to work

    dim show, verify

    verify = "test"

    show = Request.Cookies("workplz")

    If verify = show
    Then Response.Redirect "http://www.google.com"

    End If

    If Request.Form("valuepassed") ="true" Then
    Mailform
    Else
    Techform
    End If

    Sub Mailform
    'Dim queinfo, questr


    Dim prod
    prod = "test"

    Response.Cookies("workplz")= prod
    Response.Cookies("workplz").Expires = Date + 1

    Dim myMail
    Set myMail = CreateObject("CDONTS.NewMail")
    HTML = "<!DOCTYPE HTML PUBLIC ""-//IETF//DTD HTML//EN"">" & NL
    HTML = HTML & "<html>"
    HTML = HTML & "<head>"
    HTML = HTML & "<title>Tech Form</title>"
    HTML = HTML & "</head>"
    HTML = HTML & "<center><b>Tech Form</b></center>"
    HTML = HTML & "<br> <b>Name: </b>" & Request.Form("Name")
    HTML = HTML & "<br> <b>Email: </b>" & Request.Form("Email")
    HTML = HTML & "<br> <b>Operating System: </b>" & Request.Form("OS")
    HTML = HTML & "<br> <b>Order Number: </b>" & Request.Form("Order")
    HTML = HTML & "<br> <b>RAM: </b>" & Request.Form("RAM")
    HTML = HTML & "<br> <b>Connection: </b>" & Request.Form("Connection")
    HTML = HTML & "</body>"
    HTML = HTML & "</html>"
    HTML = HTML & "</body>"
    HTML = HTML & "</html>"

    myMail.From = "test@test.com"
    myMail.To = Request.Form("Email")
    myMail.Subject = "Re: Tech Form"
    myMail.BodyFormat = 0
    myMail.MailFormat = 0
    myMail.Body = HTML
    myMail.Send
    Response.Redirect "http://www.yahoo.com"

    Techform
    End Sub
    %>


    <% Sub Techform %>
    <body bgcolor="#ffffff">
    <form name="form" action="rr.asp" method="post">
    <input type="hidden" name="valuepassed" value="true">
    <table width="576" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td width="574" valign="top"><table width="100%" cellspacing="0" cellpadding="0">
    <tr>
    <td colspan="2"><div align="center"><strong><FONT face="Arial, Helvetica, sans-serif" size="4">Tech Form </FONT></strong><br>
    <br>
    </div></td>
    </tr>
    <tr>
    <td colspan="2"><div align="center">
    <p><FONT face="Arial, Helvetica, sans-serif" size="2">Provide as much information
    as
    possible
    so we can answer the question quickly and accurately.</FONT></p>
    </div></td>
    </tr>
    <tr>
    <td colspan="2"><table width="100%" cellspacing="0" cellpadding="0">
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td width="34%"><font size="2" face="Arial, Helvetica, sans-serif"><strong>Your Name <font color="#FF0000">*</font></strong></font></td>
    <td width="35%"><font size="2" face="Arial, Helvetica, sans-serif"><strong>Email
    Address<font color="#FF0000">*</font></strong></font></td>
    <td width="31%"><font size="2" face="Arial, Helvetica, sans-serif"><strong>Windows OS</strong></font></td>
    </tr>
    <tr>
    <td><font face="Arial, Helvetica, sans-serif">
    <INPUT type="text" name="Name" size="25" maxlength="40">
    </font></td>
    <td><font face="Arial, Helvetica, sans-serif">
    <INPUT name="Email" type="text" id="Email" onBlur="MM_validateForm('Email','','RisEmail');return document.MM_returnValue" size="25" maxlength="40">
    </font></td>
    <td><FONT color="#FF0000" face="Arial, Helvetica, sans-serif">
    <SELECT name="OS">
    <OPTION>Windows 3.1</OPTION>
    <OPTION>Windows 95</OPTION>
    <OPTION>Windows NT</OPTION>
    <OPTION>Windows 98</OPTION>
    <OPTION>Windows ME</OPTION>
    <OPTION>Windows 2000</OPTION>
    <OPTION selected>Windows XP</OPTION>
    <OPTION>Windows 2003</OPTION>
    </SELECT>
    </FONT></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td><font face="Arial, Helvetica, sans-serif"><strong><FONT size="2">Order Number <font color="#FF0000">*</font>&nbsp;</FONT></strong></font></td>
    <td><div align="left"><font face="Arial, Helvetica, sans-serif"><strong><FONT size="2">Amount
    of RAM?</FONT></strong></font></div></td>
    <td><font face="Arial, Helvetica, sans-serif"><strong><FONT color="#FF0000"><FONT color="#000000" size="2">Connection
    Speed?</FONT></FONT></strong></font></td>
    </tr>
    <tr>
    <td><FONT face="Arial, Helvetica, sans-serif" size="2">
    <INPUT name="Order" type="text" id="Order" onBlur="MM_validateForm('Email','','RisEmail','Product','','R');return document.MM_returnValue" size="25" maxlength="12">
    </FONT></td>
    <td><font face="Arial, Helvetica, sans-serif">
    <INPUT name="RAM" type="text" id="RAM" size="25" maxlength="25">
    </font></td>
    <td><FONT color="#FF0000" face="Arial, Helvetica, sans-serif"><B>
    <select name="Connection">
    <option selected>Dial Up</option>
    <option>DSL</option>
    <option>Cable</option>
    <option>T1</option>
    <option>T3</option>
    </select>
    </B></FONT></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td colspan="2"><font face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
    </tr>
    <tr>
    <td><div align="center">
    <font face="Arial, Helvetica, sans-serif">
    <input name="Submit" type="submit" onClick="MM_validateForm('Name','','R','Email','','RisEmail','Order','','R');return document.MM_returnValue" value="Submit">
    </font></div></td>
    <td><div align="center">
    <font face="Arial, Helvetica, sans-serif">
    <input type="reset" name="Reset" value="Reset Form">
    </font></div></td>
    </tr>
    <tr>
    <td colspan="2"><div align="center"><br>
    <font color="#0000FF" size="2" face="Arial, Helvetica, sans-serif">** Our technical support team <strong></strong>has a normal response time of less than 1 business day. Depending on support volume and customer&rsquo;s it could take up to 3 business days **</font></div></td>
    </tr>
    </table></td>
    </tr>
    </table>
    </form>
    <% End Sub%>

  2. #2
    Join Date
    Dec 2004
    Posts
    8,637

    Re: Cookie Problem

    Originally posted by Athmaus
    Yet i am having a problem with the page.
    You gonna do more than just outline the scenario and provide boat-loads of code? How about error messages or other symptomatic erroneous results?

  3. #3
    Join Date
    Apr 2004
    Location
    TX
    Posts
    94
    see here lies the problem....

    All i know is the problem is located with the Cookie code (request or response), i am unsure which line as i am with IT as well trying to get it fixed so i can debug it.

  4. #4
    Join Date
    Dec 2004
    Posts
    8,637
    OK, I think maybe you're refering to the expiration of the Cookie not being what you want it to be. This is the problem:

    Response.Cookies("workplz").Expires = Date + 1

    That will not give you a Cookie that expires one day from today. If it works, then it probably gives you a Cookie that expires one milli-second or one second from the current time.

    Check out the DateAdd function.

  5. #5
    Join Date
    Apr 2004
    Location
    TX
    Posts
    94
    I edited that and i still get the same error....

    I believe my problem lies with this part:

    dim show, verify

    verify = "reg"

    show = Request.Cookies("3breg")

    If verify = show
    Then Response.Redirect "http://www.google.com"

    Else

    If Request.Form("valuepassed") ="true" Then
    Mailform


    Where i am tryin to find the cookie and read it

  6. #6
    Join Date
    Dec 2004
    Posts
    8,637
    What error? You didn't mention anything previously about getting errors! I specifically asked you that question.
    Originally posted by Athmaus
    I edited that...
    Show what you edited.

  7. #7
    Join Date
    Apr 2004
    Location
    TX
    Posts
    94
    Originally posted by phpnovice
    What error? You didn't mention anything previously about getting errors! I specifically asked you that question.

    Show what you edited.
    and i freakin answered it here: All i know is the problem is located with the Cookie code (request or response), i am unsure which line as i am with IT as well trying to get it fixed so i can debug it. All iget is an Internal Server Error.

    I do not know WHERE the error is exactly at the moment until the techs fix the "friendly" error page on the server. All i know that it is with the Request.Cookies OR Response.Cookies. If i take both out the form works fine.

  8. #8
    Join Date
    Dec 2004
    Posts
    8,637
    Originally posted by Athmaus
    ... until the techs fix the "friendly" error page on the server.
    This does not require a "tech". You must be using IE. Go here:

    Tools / Internet Options... / Advanced / Browsing

    and make sure this is unchecked:

    Show friendly HTTP error messages

    Otherwise: Show what you edited!

  9. #9
    Join Date
    Apr 2004
    Location
    TX
    Posts
    94
    Originally posted by phpnovice
    This does not require a "tech". You must be using IE. Go here:

    Tools / Internet Options... / Advanced / Browsing

    and make sure this is unchecked:

    Show friendly HTTP error messages

    Otherwise: Show what you edited!
    Well duh! It it unchecked. LIke i said a tech is in process of fixin it.

    And the "edited" part is what you asked me to try the DateAdd function. that is all........

  10. #10
    Join Date
    Dec 2004
    Posts
    8,637
    Originally posted by Athmaus
    And the "edited" part is what you asked me to try the DateAdd function. that is all........
    Yes, but I want to see how you coded it.

  11. #11
    Join Date
    Apr 2004
    Location
    TX
    Posts
    94
    Dim prod, xdate
    prod = "test"

    xdate = Now()

    Response.Cookies("workplz")= "test"
    Response.Cookies("workplz").Expires = DateAdd("d", 7, xdate)
    Last edited by Athmaus; 03-16-2005 at 02:49 PM.

  12. #12
    Join Date
    Dec 2004
    Posts
    8,637
    Definitely need actual error message information -- rather than just guessing.
    Try changing this:
    Code:
    If verify = show
    Then Response.Redirect "http://www.google.com"
    
    End If
    to this:
    Code:
    If verify = show Then
        Response.Redirect "http://www.google.com"
    End If

  13. #13
    Join Date
    Dec 2004
    Posts
    8,637
    I also believe that you cannot do a Redirect if you have already sent some HTML to the client.

  14. #14
    Join Date
    Apr 2004
    Location
    TX
    Posts
    94
    The techs fixed the problem with the friendly errors.

    I left out an "End If" statement in the beginning. Once i put the end If after the first end if, the entire thing works.

    Thanks for your help.

  15. #15
    Join Date
    Apr 2004
    Location
    TX
    Posts
    94
    Hey!

    I have another problem now. I have another cookie that users will get when they get to our ecom. Hwo can i read this cookie on the form. I made the cookie on the ecom but i do not know how to access it on these forms since it is made on another domain.....


    I found this but to be honest snippit online, I am at a loss here

    <%

    UID=Request.Cookies("UID")

    If ((IsNull(UID)) OR (Len(UID)=0)) Then

    strURL=Request.ServerVariables("URL"))
    strQueryString=Request.ServerVariables("QUERY_STRING"))


    If (Len(strQueryString)>0) Then
    strReturn= Server.URLEncode(strURL & "?" & strQueryString)
    Else
    strReturn= Server.URLEncode(strURL)
    End If

    Respone.Redirect("http://myserver.com/slave.asp?Return=" & strReturn)

    End If
    %>

    All i need to do is read the cookie from another domain that i named "test" than make sure it has "yes" as the value.

    Any ideas?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.45707 seconds
  • Memory Usage 3,030KB
  • Queries Executed 13 (?)
More Information
Template Usage (37):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (2)bbcode_code
  • (6)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (15)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (15)postbit
  • (15)postbit_onlinestatus
  • (15)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (72):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates