1

I want to use an opencart database for another website, so users don't need to register their details again.

For example: I sell Clothes (unStitched) on opencart and I also give services for stitching them. Opencart doesn't have a module to do this, so I want to redirect users to another website and there I want to read the user details for further processing.

How can I read PHPSESSID cookie? How does opencart read firstname on edit profile forms?

<?php echo $firstname; ?>

Thanks in advance.

theduck
  • 2,589
  • 13
  • 17
  • 23
Anmol singh
  • 158
  • 1
  • 12

1 Answers1

1

In order to work with the Session data in an Opencart view, you will need to add some code to the controller. First we need to add an item in the $data array that the controller uses to pass variables to the view:

Assuming you want to show this link in a product view, you will need to edit the product controller's index action.

Controller file: public_html\catalog\controller\product\product.php

Find this line:

if ($product_info) {

Add the text inside the brace:

    $data['mysessionvariable'] = $this->session;

You can restrict the available data to the sessionID only using the code below:

    $data['mysessionvariable'] = $this->session->getId();

Now the relevant PHP Session data is available to the view, you can simply reference the session variable in the view wherever your need to. e.g. echo $mysessionvariable['session_id']; or echo $mysessionvariable;

View file: public_html\catalog\view\theme\default\template\product\product.tpl

Daniel
  • 2,167
  • 5
  • 23
  • 44