Documentation / Tutorials / Awesome Enterprise,Generic,Quick Samples,SPA
Session ticket and AJAX
/ Awesome Enterprise,Generic,Quick Samples,SPA / Session ticket and AJAX
- Use ticket while executing AJAX, which provides much of security rather than calling module directly through name.
- Following are then syntax’s 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:
-
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' /]
If you need to send any extra parameter in request, in that case also use ticket rather than 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 spa script tag with other details of 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
Get all ticket data
-
-
12---- <strong>template.otp_ticket_id</strong> is already set with session ticket data[session_ticket.get main='{template.otp_ticket_id}' o.set=@template.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
-