Published on 03/05/2020
Published by Pratik Takle
Session ticket and AJAX
- Use ticket while executing AJAX, which provides much of security rather than calling module directly through name.
- Following are the syntaxes and examples:
To generate session ticket :
- Syntax :
-
1234[session_ticket.create {token} set=template.ticket_id /][arr.create set=template.clxn][post_type]{either a service slug or collection slug of app}[/post_type][/arr.create]
- Eg:
-
1234[session_ticket.create {token} set=template.ticket_id /][arr.create set=template.clxn][post_type]enq_service[/post_type][/arr.create]
Set activity for session ticket
- Syntax (app – module):
-
123[session_ticket.set_activity {template.ticket_id}collection='{collection_name}'module='{module_slug}.{template_slug}' /]
- Eg:
-
123[session_ticket.set_activity {template.ticket_id}collection='{template.clxn}'module='response_section.handler_mail_send' /]
- Syntax (app – Service):
-
12[session_ticket.set_activity {template.ticket_id}app='system' service='{service_slug}.{module_slug}' /]
- Eg:
-
1[session_ticket.set_activity {template.ticket_id} app='system' module='response_section.handler_mail_send' /]
If you need to send any extra parameter in a request, in that case also use a ticket rather than a script attribute
- Syntax:
-
1[session_ticket.set {template.ticket_id} field='{field_name}' value='{value}' /]
- Eg:
-
12[session_ticket.set {template.ticket_id} field='parent_form' value='{module.parent_form}' /][session_ticket.set {template.ticket_id} field='dept' value='{module.dept}' /]
At last, write the spa script tag with other details of the script call.
- Syantax:
-
123456<script type='spa/axn'axn='{any of the action of spa ie. form.ajax, form_upload.ajax etc}'bind='{bind event}'bind_selector="{bind element}"route_ajax='t/{ticket_variable}' ></script>
- Eg:
-
123456<script type='spa/axn'axn='form_upload.ajax'bind='submit'bind_selector="#[module.token/]"route_ajax='t/[template.ticket_id /]' ></script>
URL to use Ticket
-
-
12Web URL: <site_url>/t/<ticket_id>SPA: route_ajax="t/<ticket_id>"
-
Use to manually handle ticket validation
-
-
1route_ajax="ticket-handler/<ticket_id>/submit"
-
Ticket handler
- Please visit: https://awxdocs.com/tutorials/ticket-handler/
Get all ticket data
-
-
12---- <strong>template.otp_ticket_id</strong> is already set with session ticket data
-
Destroy Ticket
-
-
1[session_ticket.destroy {template.otp_ticket_id} o.set=template.temp/]
-
Update ticket validity
-
-
123[module.set ticket="5c75188e1d719" /][session_ticket.set_timeout {module.ticket} time=120 o.set=module.x /]time=120 in minutes
-