Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7070265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:32:45+00:00 2026-05-28T05:32:45+00:00

I am trying to create a session deletion method for cookies on logout. Cookies

  • 0

I am trying to create a session deletion method for cookies on logout.

Cookies with a certain start key need to be deleted, so I have made a little javascript that works.

Trying to keep all my Logout code in one place, I am trying to added the Javascript dynamically.

In my Code Behind, I am doing the following:

    Dim logoutJS As String = ""
    logoutJS += "function loadJQuery(callback) {  "
    logoutJS += "var addJquery = document.createElement('script'); " '// add jQuery to document
    logoutJS += "addJquery.onload = callback;  "
    logoutJS += "addJquery.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'; "
    logoutJS += "document.getElementsByTagName('head')[0].appendChild(addJquery); "
    logoutJS += "  }; "
    logoutJS += "function loadCookies() { " '// now jQuery is loaded we can used getScript
    logoutJS += "$.getScript('/Scripts/jquery_cookies_min.js', deleteCookies()); "
    logoutJS += "  };"
    logoutJS += "function deleteCookies() { "  
    logoutJS += "var cookieSettings = $.cookies.filter(/^hgAdmin/); "
    logoutJS += "$.each(cookieSettings, function (cookieName, content) { "
    logoutJS += "$.cookies.del(cookieName); });        "
    logoutJS += "window.location = ('/login.aspx'); };"
    logoutJS += "loadJQuery(function() { loadCookies(); }); "

    Common.logOut(Session)
    ScriptManager.RegisterStartupScript(form1, GetType(HtmlGenericControl), "form1", logoutJS, True)

Obviously logoutJS is the Javascript to be called when the logout page loads, this then redirect back to login.

When manually inserted into the page and physically coding the inserted JS files, this works fine.

However, when dynamically inserted, the $.getScript('/Scripts/jquery_cookies_min.js', deleteCookies()); is not working correctly.

The problem is, the jquery_cookies_min.js file is NOT loaded when the callback to run deleteCookies is fired so I get an console error cannot call method 'filter' of undefined.

If I change the script loaded by getScript to a different script, another copy of jQuery for example, then it loads (I can see the Chrome Network console shows jQuery laoded twice), but it won’t load this Cookies file.

I have checked and double checked a million times that the location is correct… and indeed, it works if I manually include the JS file… I’ve also tried without the preceding /

Why is this script not loading?!

EDIT: I have also tried with the appendChild element method as per the manner in which I am loading jQuery… same result

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:32:46+00:00Added an answer on May 28, 2026 at 5:32 am

    Because your second param is a function call, not a function definition or reference.

    Try removing the () from deleteCookies() or use:

    $.getScript('/path', function () { deleteCookies() });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little issue with my coding. I am trying to create 2
I am trying to create a single sign on process. The method I have
Trying to create a request only to have a runtime error thrown. Method initiating
A little background: I am trying to create a lightweight cookieless database-backed user session
I am trying create a delegate representation of constructor by emitting a Dynamic Method,
I'm trying to create a log when an authenticated user creates a new session,
I'm trying to create an HttpWebRequest/HttpWebResponse session with an ASP.NET website to later parse
I am trying to update/create session variable when I change the option thru a
I'm trying to create a PHP Session Wrapper Class and to do it -
I'm trying to create a custom session ID generator. From what I've read across

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.