We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Cookie Monster

snocross
snocross asked
on
Medium Priority
357 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!
Comment
Watch Question

Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
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

Commented:
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

Author

Commented:
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?
You have to use methods of JS to write cookies while submitting the form or during exit event of the fields ?? Need Code ???

Author

Commented:
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!!
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

Author

Commented:
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?
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
Ok thanks... will award points soon...

Author

Commented:
Thanks everyone!
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.