Solved

Cookie Monster

Posted on 2004-04-09
11
332 Views
Last Modified: 2013-12-18
I would like to have a form on my web page where there is two fields;  NAME and COMPANY.  The user will press SUBMIT and the values they type in for these fields will be stored on their computer.

After they have hit submit and the cookie has been stored I want to put them into a new ORDER ENTRY form that will contain their NAME and COMPANY in two fields.  From this point forward when they perform activities I will have these two values that I will be able to FLAG to all their transactions.

Can anybody help with doing this?  I have successfully created cookies before but never based upon a value that they type... my cookies have always been hard-coded values.  Plus I have set the cookie in the $$HTMLHeader which I believe sets the cookie upon LOADING instead of when the user submits the form.

Can anybody help?  Thanks!
0
Comment
Question by:snocross
11 Comments
 
LVL 31

Accepted Solution

by:
qwaletee earned 80 total points
ID: 10793669
Is there any need to submit the form?  You can use Javascript to set the cookie, and once the cookie is set, the Javascript can navigate to your order entry form!

Actually, I think a better way to do it would be to set the two fields to be editable, based on a cookie.  When the user submits, the result page should set the cookie to whatever was submitted.

The way this works is not terribly complicated.  Your $$Return or WebQuerySave redirects to a URL.  Append the cookie values to the URL.  The HTML head stuff can set the cookie based on this URL.  if the URL is another order entry form, you may also need to program the default values to look at the query string before looking at the cookie, because Domino will, I think, be evaluating based on the old cookie value that was sent with the URL request, not the new one being set via the URL.

An alternative: Have your onSubmit code set the cookie to whatever is currently in the fields.  Do not put in a default formula at all.  Have your onLoad take the current cookie values and place them in the HTML fields.  All the cookie code will then be on the client side.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10793867
Sno, It is easier to retrieve cookie value. Create a field Called HTTP_Cookie, computed with "" as value.

This will extract any cookie stored in local machine for the site and path it was stored against.

~Hemanth
0
 
LVL 14

Expert Comment

by:p_partha
ID: 10801635
Sno, What hemanth has mentioned holds good for session based cookie, You can easily get the value of the Cookie from HTTP_Cookie, but when the session gets closed, still u want it to be done, then you can think abt storing information related to his IP address and the information.. Something like his ip address, and the values .. which u can compare and display anytime

partha
0
 
LVL 5

Author Comment

by:snocross
ID: 10813515
Ok so far I have a logon form with an $$HTMLHead field with the following formula;

"<META HTTP-EQUIV=\"Set-cookie\" CONTENT=\"FirstName=PatrickLastName=BachmannCompany=Barber FoodsEnd=;path=/;expires=Saturday, 031-Dec-05 12:00:00 GMT;\">"

Now on this same form I have a NAME field and a COMPANY field that pull in the information from the cookie by referencing the HTTP_Cookie field;

NAME FIELD:
@Middle(HTTP_Cookie;"FirstName=";"LastName=")+" "+@Middle(HTTP_Cookie;"LastName=";"Company=")

COMPANY FIELD:
@Middle(HTTP_Cookie;"Company=";"End=")

Ok life is good at this point... the fields default to my hardcoded name and company however now I want them to be able to type any name and company they choose and the cookie code to reference these two fields.  

1) How can I do this?
2) If I do this in the $$HTMLHead field then won't it execute BEFORE the new values are entered?  Don't I need to set the cookie somehow AFTER they have typed the values?  Is this where I should simply pass the values in the URL to a second form that will then set the cookie upon loading?
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10813585
You have to use methods of JS to write cookies while submitting the form or during exit event of the fields ?? Need Code ???
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 5

Author Comment

by:snocross
ID: 10813894
But I almost have it!  I'm now have a LOGIN button and it passes the values to a second form in the URL.  The second form sets the new cookie to be the same as the values passed in the URL however the second form doesn't display the new cookie until I REFRESH it.  Seems the HTTP_Cookie field is not evaluating until RESAVED.  It seems to be happening in this order on the second form;

1) HTTP_Cookie Gets current cookie (Retreives old cookie)
2) $$HTMLHead Sets new cookie from URL

It happens in this order even though the $$HTMLHead field is FIRST on my form!!
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10814018
Yes that is the way it evaluates.. In your case you have to set cookie before going to the next form.. That would be during onLoad event of the document
0
 
LVL 5

Author Comment

by:snocross
ID: 10814148
Ok I think I have solved it by using a third form!  Ugly but it works.  Now the problem will be preventing users from BOOKMARKING a page and bypassing these forms.  Maybe somehow if the user is ANONYMOUS and a cookie is not found then force them back to the LOGIN screen?
0
 
LVL 24

Assisted Solution

by:HemanthaKumar
HemanthaKumar earned 45 total points
ID: 10814271
In the onLoad even of the form.. paste this code

if( document.forms[0].HTTP_Cookie.value == "") {
alert("No Login information found" )
location.replace( "url redirection goes here " );

}

Also enable generate html for all fields, so that if http_cookie is computed and hidden it is available for the Javascript.
0
 
LVL 5

Author Comment

by:snocross
ID: 10814540
Ok thanks... will award points soon...
0
 
LVL 5

Author Comment

by:snocross
ID: 10825924
Thanks everyone!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now