Jump to content

[CONTRIBUTION] Passing the SessionID


A-Z Hosting
 Share

Recommended Posts

One of the wonderful things about building stores with PHP is having the ability to work with bridges and writing custom pieces. However, with PrestaShop using cookies instead of sessions it puts a damper on using that common session information to work outside of itself.

Here's the start of a little hack that I'm using to solve this issue. It wouldn't add much to the prestashop footprint if the developers decided to add it in. Consider this my plea to the wishlist.

config/settings.inc.php

after: 
define('_PS_VERSION_', '1.3.2.3');

added:
session_start();
define('_SESSION_', session_id());


[/code]

classes/Cookie.php

after:
  /** @var array 8 chars Blowfish initilization vector */
  private $_iv;

added:
  private $_sess;

and after:
  $this->_key = _COOKIE_KEY_;
  $this->_iv = _COOKIE_IV_;

added:
  $this->_sess = _SESSION_;



As you can guess yes this adds the sessionid to the $cookie information passed around server side. One needs only throw a config and init into their own php pages or scripts and pull the presta cookie info in to work with.

require_once(dirname(__FILE__).'/config/config.inc.php'); //or whatever path you require
require_once(dirname(__FILE__).'/init.php'); //or whatever path you require
$cookie = new Cookie('ps');

This is just the beginning of this hack. I would see it growing into an additional column that stores the sessionid along with id_guest and even post login but I haven't gotten there yet. Would open the doors to better development around the store.

Open to suggestions, complaints and outright flaming. ;-)

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More