Jump to content

Help w/Cookies...


This topic is 8608 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hello all.

I have search the message boards here, and I can't seem to find a topic that fits my situation. I hope someone can help.

We have a FM database called graphic library. We have set this up with custom web publishing as a web page for our customers to go to to search for their graphics. We didn't want other companies looking at each other's graphics, so I set up, with the web security databases, the exact search. Each customer has a code that they must enter with each search to find their stuff. Some customers have mentioned that they don't like to have to type their code in for every search. So, cookies came to mind...

I have tried to work them in, but, with no real understand on how they function, I'm lost. I would like to do this: The customer comes to the site. They go to an initial search page that has 1 entry field, there customer code. They enter it, and click 'Submit'. Then then are sent a cookie with that code, and they are then taken to the main search page where they can enter their criteria... and they can perform numerous searches without entering their code every time.

Is this possible, or do I REALLY not understand cookies... Or does it have to do with the 'exact search'? Any help would be great. Thanks!

Jerremy

Link to comment
Share on other sites

You have to have a page inbetween the two searches so that the cookie can be registered on the persons machine.

Have them put their number in a field that say puts a new record in an access database. (a good way as well of seeing how many times they use the database).

On the results page have a meta redirect through to the second search page. This would have to be a cdml fmpro? action so the web companion changes the fmp tags in the search page.

Also put on that page :

[FMP-SetCookie: usercode=Field: fieldnamefromlastpage, Expires=2222259200]

Then on the next page that this refreshes to and that contains the searchpage put this in your form

<type="hidden" name="usercode(or whatever your field is called)" value="[fmp-cookie: usercode]">

This will be replaced with the value from your cookie.

Hope this helps

Simon

Link to comment
Share on other sites

Simon, thanks for your help!

You got me 90% there I believe... My initial search page is called search.html. Using what you said, I created 2 more files, index.html and cookie.html. I also created a database 'Access'. The index.html prompts you to enter a code. This code is entered into 'Access'. This file then loads cookie.html. This is where I seem to have a problem...

The cookie is sent, I see it listed in my Explorer prefs under cookies... But as this page is loaded, I get a error evey time. Here is the code of the page... Can you see what I am doinf wrong?...:

<meta http-equiv="refresh" content="3;

URL=FMPro?-db=Access&-lay=Layout%20#1&-format=search.html">

<meta name="generator" content="Adobe GoLive 4">

<title></title>

</head>

[FMP-SetCookie: CodeCookie=Field: YourSecretCode, Expires=0]

I have tried MANY combinations in that URL... I can't get it right. any suggestions?

I do get the cookie in the browser, it just won't continue to the next page.

Any ideas would be great.

Jerremy

Link to comment
Share on other sites

Your problem is that the url is not finding anything. It must have an action tag at the end.

I am not sure that -view would work is web companion wouldn't parse out the tags for the cookies.

How about finding the access entry that has just been added.

I have just had a thought you don't need to use cookies or a middle page if you use the access database. You can just pass the code around with a token. This I believe would be more robust than cookies as people can have cookies turned off in their browser but not tokens.

Here goes.

The first page stays the same. The person enters their id number into field id_number (or whatever you've called it. They then get the next page which is your search page and you add two lines into the search form.

<type="hidden" name="id_number" value="[fmp-field: id_number]">

<type="hidden" name="-token.1" value="[fmp-field: id_number]">

They then preform the search and the id_number is passed across with the token to the next page. From then on you make sure every link has &-token.1=[fmp-currenttoken:1] in it so that it passes the id_number around.

You would then have to make a duplicate of your search page as the last one is only good for the first time that they access the search. Each subsequent time you would have them access a search page which uses the token to set the id number.

With a search line of <type="hidden" name="id_number" value="[fmp-currenttoken:1]">

This would stop the need for cookies.

If you still want to go the way off the cookie then this is what is wrong with your redirect url it should read.

FMPro?-db=Access&-lay=Layout%20#1&-format=search.html&id_number=[fmp-field: id_numberfieldfromlastpage]&-find

That will solve that problem

Can I make one more suggestion. You have used the name of the default layout that Filemaker gives you Layout #1. I suggest you rename this to something with no spaces in or use _ instead of a space. Certain items in the filemaker tags have difficulty using spaces in field names and layouts and its best to start from the beginning with out them.

Hope this clears it up, and whichever way you go I hope it works for you.

Simon

Link to comment
Share on other sites

Simon,

That's it. Thanks for your help! I used your exact string for the URL and it would not work... As a last ditch effort, I renamed my layout to 'Form' from Layout #1. That did the trick. Thanks for that little tidbit at the end of your post.

1 more question... I can now do the search, flip through a few of the pages of that search, then click the back button in my browser back to the search page. I can then do another search, it still has my cookie registered. But, when I click on my 'new search' link (on one of the result pages) and go back to the search page, I lose the cookie. Do I need to 'retrigger' the cookie somehow in the link back to the search page?

Simon, thanks for your help with this. I can see the light at the end of all this. I owe ya a beer.

Thanks,

Jerremy

Link to comment
Share on other sites

Have you made sure that the link you are clicking on from the other pages is exactly the same as on your redirect page. If it is the cookie should register. You have to make sure that you have an action tag on the end of the url. ie -find, but not -view as it won't parse out the tag codes. You don't need to do anything to make the cookies re appear just make sure the page is a result of an action.

I am glad I could be of assistance.

Simon

I added later:::

The above won't work as the redirect page uses the result of a field that they have entered in the page before. Of course when they use a link later on they haven't just entered the data into the field to use it in the link. You need to change the field to use the cookie.

FMPro?-db=Access&-lay=form&-format=search.html&id_number=[fmp-cookie: yoursecretcode]&-find

I think that should now work.

Simon

[This message has been edited by Simonpennington (edited December 17, 2000).]

[This message has been edited by Simonpennington (edited December 17, 2000).]

Link to comment
Share on other sites

I agree with the guy above, as I said earlier cookies are unrliable and I still believe that you can get away with using tokens and fields. but if you do keep on the cookie way then I have had the following thoughts.

Right rethinking my answers from before here are some problems that i can see that you will have.

The person puts in their code. Add a new record to your access database and get the next page which adds the cookies and takes them on to the next page which adds the cookies to the search criteria. Fine so far.

When they get the results page they probably then choose a search result and get a further page of details. If you put a link on that page to the search page then you need to make it as I said above, finding the access code in the access database. Prblem I can see is that after they have been in once then they are going to find more than one instants of their code therefore you have to add in to the link &-max=1 Because they are basically doing the same search as the redirect page you do not need two versions of the search page as the page they get to after the redirect will be good enough as you would have found the record which would then put the code in where the fm tags are for it in the search form.

I think this is right now.

I still suggest that you use my token version above as it is much more robust than cookies.

with a token version you would put in the link url &in_number=[fmp-currenttoken:1] and that would put the code in. If you have used the [fmp-link] code in the results page throught o the more details page then the token would have gone to the next page as well

If you have this online I wouldn't mind having a go to see if you have any other problems

(if you want you can email me the link and a code)

Simon

[This message has been edited by Simonpennington (edited December 17, 2000).]

Link to comment
Share on other sites

Simon and others:

Thanks for your help. Simon, I used your token idea. It's perfect. Users can now enter their code on the first page - then they are set for all their searches. I just had to tweak my pages a bit. I have Flash headers on the a pages w/a new search button in the header. I have to pull that out and put the link into the body w/the FM code... Not a big deal.

Thanks again for your help!

I now owe ya 2 beers,

Jerremy

Link to comment
Share on other sites

This topic is 8608 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.