0

We are developing shopping cart application. Our application we are merging the cart items with login user when user logged in. So can you please help me how to use Session inside the model

N Nem
  • 743
  • 8
  • 14
venkat
  • 11
  • 1
  • 6

1 Answers1

3

One workaround is using Network Session object

// In Table class include this line at the top
use Cake\Network\Session;

public function getSession(){
   $session = new Session();
   debug($session->read()); die;
} 

I don't know whether it's optimal solution or not. Other way of doing is discussed here Session accessibility in model and behavior

Community
  • 1
  • 1
N Nem
  • 743
  • 8
  • 14