Set Cookie Using Trigger Failing


(Lewis) #1

I’ve set up a trigger to create a cookie when a specific Squiz custom form is submitted. I’ve set the trigger to fire on ‘Form Submission Created’ as I guess this is the definitive end point - the form is fully submitted.

Unfortunately, when the form is submitted nothing comes through in the browser’s developers tools, showing the cookie being sent.

Any ideas?


(Iain Simmons) #2

Hi Lewis,

There’s also the Form Submission Completed trigger event, that only occurs after a successful submission.

Can you please elaborate a bit on what you intend to use the cookie for, and the other settings in the trigger? (Events, Conditions, Actions and whether you have things like ‘Ignore Permissions’ checked?)

– iain


(Lewis) #3

Hi @isimmons. Thanks for the reply!

I’m trying to create a cookie banner - yuh know, ‘we use cookies’ etc for a satellite site. I’ve tried a couple of other things yesterday too but no luck.

I’ll give your suggestion a go. I’m thinking it’s likely to be being blocked on our network or else it’s some sort of permission thing! :thinking:


(Lewis) #4

Just realised ‘Form Submission Completed’ is one I tried already. I’ve tried those two (Form Submission Completed/Form Submission Created) in different combinations but no luck. I’ve tried publishing the page where I’ve nested the form, I’ve tried going direct to the Custom Form and I’ve tried setting the cookie domain and path in the trigger’s settings but still nothing.

I even tried off out network, on my own install of Squiz demo VM but it still doesn’t work so I’m pretty sure it’s a setting somewhere that is wrong now @isimmons


(Iain Simmons) #5

Is the cookie http only and are you accessing it via JS?

It might actually be easier to just use JS to set and get the cookie value. Then you don’t really have to worry about caching.


(Lewis) #6

I’m not accessing it through JS but it is being served over http.

I would rather have server side where I can, just means we’re less reliant on individual’s browsers although I guess I could use SSJS @isimmons?


(Bart Banda) #7

Is the trigger firing at all? You can confirm and check the logs to see if the trigger fires successfully first. I wonder if http rather than https also is causing an issue with it not being sent?
Also, have you tried other trigger events just to test the concept out? Like create a trigger that fires on asset accessed and then sets a cookie, just to confirm that you can actually do it on your instance and server. There may be a reverse proxy that is stripping it perhaps.


(Lewis) #8

Hi @Bart. I think I may have solved this in the meantime. I’m using a redirector as part of the process as the intermediary cookie isn’t recognised when the trigger initially fires. The cookie is only recognised when the page refreshes for a second time. The redirector ensures the page does that and so I can now access the cookie.

May need to make some adjustments once it’s on a ‘live’ domain though.