Jump to content

SetCookie within InlineAction.


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

Recommended Posts

Hello & Help!

I am writing a password login page. The login page enters the username and passwords into tokens 1 and 2 and sends the data to a null database (no records using -view action).

The response page has an inline action that finds the username and password. In the inline action I want to set a cookie if the CurrentFoundCount.eq.1...

[FMP-InlineAction:-db=users,-Token.1=username,-Token.2=password,-find]

[FMP-If:CurrentFoundCount.eq.1]

[FMP-SetCookie:cookiename=field:userid]

[/FMP-if]

[/FMP-InlineAction]

The problem is it is not setting the cookie. If I insert a [FMP-field:userid] tag between the InlineAction tags I get the userid displayed on the response page so I know the find is happening correctly. I also get the "Do you want to accept the cookie?" dialog box. However, the dialog box says "cookiename=".

Another thing is the cookie set even if the CurrentFoundCount is 0. What I believe is happening is that the FMP-SetCookie is happening right when the page is loaded even before the FMP-InlineAction is processed.

My question is, how do I set a cookie value that is generated by an InlineAction -find request?

Link to comment
Share on other sites

quote:

Originally posted by Daveman:

Hello & Help!

I am writing a password login page. The login page enters the username and passwords into tokens 1 and 2 and sends the data to a null database (no records using -view action).

Why not just have the login page perform the find against the username and password stored in the database straight-away?

quote:

The response page has an inline action that finds the username and password. In the inline action I want to set a cookie if the CurrentFoundCount.eq.1...

[FMP-InlineAction:-db=users,-Token.1=username,-Token.2=password,-find]

[FMP-If:CurrentFoundCount.eq.1]

[FMP-SetCookie:cookiename=field:userid]

[/FMP-if]

[/FMP-InlineAction]

The problem is it is not setting the cookie. If I insert a [FMP-field:userid] tag between the InlineAction tags I get the userid displayed on the response page so I know the find is happening correctly. I also get the "Do you want to accept the cookie?" dialog box. However, the dialog box says "cookiename=".

My question is, how do I set a cookie value that is generated by an InlineAction -find request?

You haven't actually given your InlineAction call any parameters to perform a -Find. The way you've written it, it is just setting -Token.1 and -Token.2.

Try:

[FMP-InlineAction:-db=users, Username={CurrentToken:1}, Password={CurrentToken:2},-Find]

.

.

.

[/FMP-InlineAction]

Although I really recommend just performing the -Find from your login page instead. Keep in mind that cookies set with Set-Cookie will not "take" until the next FileMaker call, i.e. you cannot set a cookie and read from it on the same results page.

Link to comment
Share on other sites

quote:

Originally posted by Daveman:

FYI: The reason I am using tokens instead of acessing the database directly is for security. My goal is to not have the name of any of my fields or databases be visible in the HTML source. Makes it more difficult to hack!

This makes sense -- if I understand you correctly, every call via form or link is a -View to an empty database, and on the -Format page you substitute field values in InlineActions with -Tokens set by the -View. The only drawback I can see is that you're making two calls to FileMaker for every action you want to take.

quote:

Can I send a cookie within an InlineAction that usese a value generated by the InlineAction?

I don't see why not -- it has been awhile since I've actually built web pages with CDML, so this is off the top of my head. Try the revised InlineAction and post your results. If it doesn't work, you can try a couple of things:

Add [FMP-Record]...[/FMP-Record] tags within the InlineAction

Get rid of the conditional statement. If the UserID field is empty, it will set an empty cookie. Since you are likely going to be checking for a valid Cookie in subsequent calls, i.e. [FMP-If:CurrentCookie.neq.]...[/FMP-If] then this shouldn't matter.

Oh -- now that I think about it, I'm not sure if an InlineAction accepts cookie-based values very well, e.g. [FMP-InlineAction: -DB=db.fp5, Fieldname={CurrentCookie: Cookiename}, -Find]

Let me know how it goes -- again, it's been awhile and I may have forgotten something, possibly from banging my head against my desk.

Link to comment
Share on other sites

Ooops! You are right! The inline action is actually:

[FMP-InlineAction:-db=users,username={CurrentToken:1},password={CurrentToken:2},-find]

[FMP-If:CurrentFoundCount.eq.1]

[FMP-SetCookie:cookiename=field:userid]

[/FMP-if]

[/FMP-InlineAction]

Sorry about that. FYI: The reason I am using tokens instead of acessing the database directly is for security. My goal is to not have the name of any of my fields or databases be visible in the HTML source. Makes it more difficult to hack!

Can I send a cookie within an InlineAction that usese a value generated by the InlineAction?

Daveman.

Link to comment
Share on other sites

RE: Sorry about that. FYI: The reason I am using tokens instead of acessing the database directly is for security. My goal is to not have the name of any of my fields or databases be visible in the HTML source. Makes it more difficult to hack!

NOT REALY. Since FileMaker Inc. left all doors open:

http://yourserver:591/FMPro?-dbnames and all names are visible...

Link to comment
Share on other sites

This topic is 8262 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.