deleting cookie at the end of a process

Posted by RyanP13 on Stack Overflow See other posts from Stack Overflow or by RyanP13
Published on 2010-05-26T11:13:25Z Indexed on 2010/05/26 11:21 UTC
Read the original article Hit count: 264

Filed under:
|
|

Hi,

I am using the following plug in for cookies in jQuery:

https://code.google.com/p/cookies/

The issue i am having is not with the plugin but when and how to delete the cookie at the end of a quoting process.

The site i am using this on is a six step online quote and buy process.

There is Omniture event serialisation sitestat tracking applied to some of the pages. This event serialisation has to include the name of the event and a random number of which i create.

I have a generic function for this which i call at the bottom of the page like so:

serialEvent('event21:', 'payment');

Here is the function:

function serialEvent(eventNumber, eventName) {
    var sessionID = jaaulde.utils.cookies.get('sessionID');             
    var remLength = 20 - eventName.length;  
    var remSession = sessionID.substr(sessionID.length - remLength, remLength);
    var eventName = eventName + remSession;
    s.events = eventNumber + eventName; 
    }

I need to delete the cookie at the end of the process, the Thank you page but i also need the cookie 'sessionID' for the 'serialEvent' function.

As the function is called at the bottom of the page should i just write the cookie delete after it? Is that robust enough?

I need to be sure that the function has successfully been called before the cookie is deleted.

The code for deleting the cookie is quite simple:

jaaulde.utils.cookies.del('sessionID');

Thanks :)

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery