How to extend your admin login session in OpenCart 2.x

Sometimes it takes a while to edit a given product details and when you click on the [Save] button, you realise that your session have ended and all the changes that you did are now lost. Fortunately, there is an easy way to avoid this. In this post I will show you how to extend the login session with a simple OCMod file.

It’s all about the code

What you have to do: Open up your favorite text editor and create a new file ending with the following extension: *.ocmod.xml.

When you are ready with that, copy the following code and save it in the file. 

<modification>
    <name>Extend admin sessions</name>
    <version>1.0 (Initial)</version>
    <link>https://isenselabs.com</link>
    <author>iSenseLabs</author>
    <code>isenselabs_extendadminsessions</code>
  
    <file path="admin/view/template/common/footer.tpl">
        <operation>
            <search><![CDATA[</body>]]></search>
            <add position="before"><![CDATA[
                <script type="text/javascript">
                    window.setInterval(function(){ $.get(location.url); }, 60000);
                </script>
            ]]></add>
        </operation>
    </file>
</modification>

If you have done similar modifications, then you already know what you have to do. However, if this is your first time, follow the steps below:

  1. Open your OpenCart administration.
  2. Navigate to Extensions -> Extension Installer.
  3. Click on the Upload button and locate the file you just created.
  4. OpenCart will install it automatically and you will get a success message.
  5. Go to Extensions -> Modifications and click on the [Refresh] button.
  6. That’s it!

Final words

Congratulations! You have got yourself covered so you will no longer lose the changes in your products due to timed out session and the changes leave a very small footprint.

If you have any questions regarding the modifications in the post, feel free to share them in the comments section below.

 

Join 11,000+ subscribers receiving actionable E-commerce advice

* Unsubscribe any time
comments powered by Disqus