Skip to content
Advertisement

How to get the index of an array of sessions? – cakephp

Friends, I have an array where I need to get the index dynamically to be able to delete the specific session.

enter image description here

I tried to link the delete button like this in cart.ctp:

JavaScript

The idea is to pass the $cart->index variable to the method.

JavaScript

But debugging ($cart->index) the value is null.

Can you help me get the session value index? (0,1,2..)

Appreciate!

Advertisement

Answer

Your “index” appears to not be a part of the records you have saved in your session, but rather just the array index. Your loop needs to be:

JavaScript

And your link:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement