0

I'm trying to make a link that acts as the "save 2 copy" button on the edit page.

On the main page for the item, I am creating the link according to this documentation: https://docs.joomla.org/How_to_add_CSRF_anti-spoofing_to_forms

<a href="<?php 
echo JRoute::_( 'index.php?option=com_pakker&view=jj_pakke&task=jj_pakke.save2copy&id=1&'. JSession::getFormToken() .'=1' );
?>">

Which generates links like:

http://mysite.com/index.php/jj_pakke/1?task=jj_pakke.save2copy&55cdb8304fef2c8a80be2620d18ae367=1

The error I'm getting is:

security token did not match

7
  • You didn't show us when/where/how you are checking the token. Are you using the get parameter? JSession::checkToken( 'get' ) or die( 'Invalid Token' ); Commented Nov 14, 2019 at 11:49
  • I didn´t do that part, but I will check up on this and see how it works. But I think save2copy is a part of the joomla API api.joomla.org/cms-3/classes/… Commented Nov 14, 2019 at 11:52
  • I can see that the error comes from this function docs.joomla.org/API16:JControllerForm/save Commented Nov 14, 2019 at 13:47
  • You where right @mickmackusa. As in the link above, the function did not use 'get'. I change my code to use a from with 'post'.... Will you make it as an answer? Commented Nov 14, 2019 at 14:25
  • It is marked as an answer on the question that yours duplicated. Doing anything with it here is redundant.
    – Arlen
    Commented Nov 15, 2019 at 22:12

0