I create a custom page in admin panel and whant's to add "save" button in it. I get link ($save_table_link) to my controller function, that's save data, like so:
$this->url->link('module/xml_auto_upload/save_table', 'user_token=' . $this->session->data['token'], true)
and use it in the view:
<form id="form-settings" name="categorys" class="form-horizintal" action="<?php echo $save_table_link?>" method="post" enctype="multipart/form-data">
<div class="form-group">
<div class="pull-right">
<button id="btn-save-table" class="btn btn-primary" type="submit" form="form-settings">
<i class="fa fa-sync-alt"></i>
Save
</button>
</div>
<label class="control-label" for="xml-file-input">File:</label>
<input type="file" name="xml" form="form-settings" id="xml-file-input">
</div>
I expect that my controller function will execute, but opencart say's me "Invalid token-session. Log in again."
As far as I know the link for any admin
module in opencart needs to have token
. If it doesn't have the token
it will not recognise the user session, hence you get that error & get logged out.
Try replacing this
$this->url->link('module/xml_auto_upload/save_table', 'user_token=' . $this->session->data['token'], true)
to
$this->url->link('module/xml_auto_upload/save_table', 'token=' . $this->session->data['token'], true)