Server Side Cookies

You mean a browser cookie from within a server action?

Yes, is it even possible?

Dont think so but I would be happy to be corrected. Gut feeling is a server script interfering directly with the contents of a browser cookie cache would be considered an security vulnerability

We don’t have an action for that at the moment, but would not be difficult to add it.

1 Like

That would be amazing Patrick, it’s not something i do often but this system idea I had kind of needs it.

Could you do this one at the same time :grin:

1 Like

I don’t think that server-side sessions should be made available to the client-side. Also implementation would a bit difficult, since you can’t access them from the browser, you have to do that on the server-side before the page is being send to the client. An other way is using ajax request, but that is already possible by setting up a server action for that.

Probably best solution to share data between server and client is to use cookies, when you don’t set an expire date the cookie will be a session cookie. The cookie can be set on the server and being read on the client and it is available after navigation.

That is interesting information, thank you, good to know.

Funnily enough to be honest I never really have issues getting any values from server connect to app connect because I just use the set value step to access specific data i may need, my problem is normally accessing App Connect data in Server Connect.

i often reference them but have to embed that via php for example getting the current user id from a security provider like <?php $_SESSION['siteSecurityId']; ?>

Would be so much easier more in the visual spirit to be able to get them via a picker

With node we now have the server-side templates and we are investigating on something similar for PHP.

1 Like

I thought the identity was available on client side by default Brian, hmmm, maybe I am wrong, must take a look.

Would it be difficult Patrick to allow camelCase to be used in the $_GET variable names, hopefully that will be easy to implement. Sometimes we are reliant upon URL parameters that come from an API and the API could have a parameter set in camelCase which means I have to open the server action code to add the $_GET or Server Connect will change it all to lowercase after it is entered.

Just an example Paul, there are other use cases

I think the team actually removed that specifically as it was causing issues with users?

Ahh ok, makes sense, lol, thaught i had gone mad for a moment, lol

Sadly with APIs it looks like the API creators can just create whatever they like, there seems to almost be no guidelines, so they land up breaking schema by using things like length or deciding to use camelCase in their URLs, etc. So a bit of a pain trying to support stuff we have no control over.

camelCase can be used with $_GET variables. Problem was the App Connect components that didn’t support the camelCase. They where added as attribute like dmx-param:myVar="1" and when you get attributes from the DOM they are always returned in lowercase, so the attribute name became dmx-param:myvar. That’s why we now force all get parameters set in serverconnect and api components to lowercase. When setting manually in the url it is no problem to use camelCase.

2 Likes

Thanks Patrick, I understand, its not a major thing when i need a camelCase one to support an API URL parameter import, to just change that bit of code manually. Rather not break bigger things to support something that is not very common or difficult to manually fix.

Thank you for the new cookie Server Actions Patrick, much appreciated, I may be being a little silly but I actually can not find it in the Server Actions though, I saw George said it was included in Beta 5, so I assume I am just overlooking something simple.

So this probably isn’t exactly what you’re looking for but you can set a cookie by using the Set Value step, then on App Connect page/app load set the cookie manager variable to your server connect output.

1 Like

Thanks, yes thats what I am currently doing to get around things, but I have a situation now where I need to change the cookie value after a few steps are performed in the server actions, as well as run a condition to check the value. Luckily Patrick said it was an easy thing to add so I am assuming its there somewhere but just not activated in the GUI or something.
Moving forware it is going to make this particular project a little easier having it there, to be honest I should have done this a different way to start with, but it was on the whiteboard, Use Cookie? and what the whiteboard says is gospel, even though i made the whiteboard. lol.

1 Like