Skip to Content Skip to Menu

[auto actions] Check if Variable is set ( or not ) for a cookie

4 years 7 months ago - 4 years 7 months ago #316928 by smalldragoon
Hi,
I guess I shoudn't be so far from the right config. I want to check if a cookie ( JWT ) is defined or not

I created my autoaction, type code, and for action, selected code and operator " not empty " ( as in the screen shot.)
Nothing is happening, despite the fact the cookie is set of course. ( I just did a message queue saying "yes " ) for now.
is it the way I defined the variable ?
Thx
Attachments:
Last edit: 4 years 7 months ago by smalldragoon.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48437
  • Thanks: 8275
  • Karma: 1443
4 years 7 months ago #316946 by krileon
Your code isn't returning anything. Please be sure to read the parameter description carefully. You need to return a value for it to condition against something. You don't need a Code condition for that though. You can access cookies with [cookie_COOKIE_NAME] in CB Auto Actions (e.g. [cookie_JWT]) in a custom value condition.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: smalldragoon

Please Log in or Create an account to join the conversation.

4 years 7 months ago #316983 by smalldragoon
Hi
Thanks, finally I'm using as you suggested directly the "[cookie_JWT]" value.
Having that said, I'm not sure to get what you are saying regarding the return value.
I should use

return ( $_COOKIE["JWT"]), and this will be check by auto action ? am I right stating this ?

( so , maybe, should I understand that the code define in the PHP is treated like it is a function ? )
Thanks

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48437
  • Thanks: 8275
  • Karma: 1443
4 years 7 months ago #316990 by krileon

Having that said, I'm not sure to get what you are saying regarding the return value.
I should use

return ( $_COOKIE["JWT"]), and this will be check by auto action ? am I right stating this ?

Yes, you need to actually return something in your PHP. This is clearly stated in the parameters description. In your case you'd have the below.

Code:
if ( ! isset( $_COOKIE["JWT"] ) ) { return null; } return $_COOKIE["JWT"];

( so , maybe, should I understand that the code define in the PHP is treated like it is a function ? )

Yes, the code condition is meant to allow executing custom code to return a value from PHP to condition against. It should only be used if absolutely necessary.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum