1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Rep Power

    Cookie PHP or jQuery in Accordion script

    have two websites. On this websites i want to apply jquery script "Accordion". I tried to install module "Accordion" to Drupal but this does not work well. I want to do it by myself, the script is already written and working good but I have a problem with the functionality. I want make it that: when you click on any link, the last selected Accordion bookmark was automatically opened. The solution is of course to use a sessions. My question is, what is better in this case:
    - Cookies jQuery
    - PHP cookies
    Is there a significant difference between them? Which of them should take advantage of and use.
  2. #2
  3. Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    London, UK
    Rep Power
    Welcome to DevShed, Alex.

    A cookie is a cookie, however you choose to create it. If the cookie is only going to be used in conjunction with your Javascript accordion, then it would seem logical to create it in Javascript.
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]
  4. #3
  5. Mad Scientist
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2007
    North Yorkshire, UK
    Rep Power
    Cookies are client side packets of information

    Whether they are set by PHP or by Javascript - they are the same thing.

    Both PHP and JavaScript can read and set cookies

    Packets of information stored server side are known as "sessions" and quite often use a cookie for identification.

    what a jquery accordian has to do with server side stuff....i'm not sure, i don't understand drupal. I would have assumed it would have been a jquery plugin referenced in your template and then used in your javascript
    I said I didn't like ORM!!! <?php $this->model->update($this->request->resources[0])->set($this->request->getData())->getData('count'); ?>

    PDO vs mysql_* functions: Find a Migration Guide Here

    [ Xeneco - T'interweb Development ] - [ Are you a Help Vampire? ] - [ Read The manual! ] - [ W3 methods - GET, POST, etc ] - [ Web Design Hell ]
  6. #4
  7. No Profile Picture
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Tempe, AZ
    Rep Power
    I'm not 100% sure if I'm understanding your use case correctly, but it sounds like the part of the accordion you want expanded relates to whatever URL was clicked to get to the page.

    If that's the case then the most full proof model would be for your PHP logic, when outputting the HTML, to set whatever needs to be set to expand the part based on the URL that kicked off the PHP.

    That way if someone shares the URL and you have people going to it directly, the resulting accordion will be expanded correctly.

    Make sense?
    It's a little hard to explain.

    Under normal circumstances a Javascript-based cookie would be the easiest way for a given browser to remember the state of accordions/expandable areas, but then they wouldn't be linked to specific URL clicks.
    LinkedIn: Dave Mittner

IMN logo majestic logo threadwatch logo seochat tools logo