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

  • SEARCH
  • Home
  • 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 5929193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:23:24+00:00 2026-05-22T14:23:24+00:00

I load a panel (html) via Jquery (ajax), in the panel there is a

  • 0

I load a panel (html) via Jquery (ajax), in the panel there is a loginform with a checkbox. I want to set the username in a cookie once the user clicks the checkbox (remember me). It is not working. Is there a solution?

$('#cookie').bind('change', function() {
       $.cookie("log_user", $("#log_user").val(), {expires: 14});
       $.cookie("log_pass", $("#log_pass").val(), {expires: 14});
});

  $("#gate").click(function () {
    var panel = $("#panel");
    if (!panel.data("loaded")) {
        $("#panel").load("/v3/ajax/panel.php");
        panel.data("loaded", true);

        var log_user = $.cookie('log_user');
        var log_pass = $.cookie('log_pass');
        // autofill the fields
        $('#log_user').attr("value", log_user);
        $('#log_pass').attr("value", log_pass);

    }
    panel.slideToggle("slow");
});




<form action="/members/login.php" method="post">
<label for="log_user">Username</label><input id="log_user" type="text" name="user" value="" maxlength="50"  /><br />
<label for="log_pass">Password  </label><input id="log_pass" type="password" name="pass" value=""  maxlength="50"  /><br />
<input id="cookie" type="checkbox" name="cookie" value="do" style="border: 0px;" /><label for="cookie"><small>Remember me</small></label><br />

<a title="Join Sionvalais" href="/members/register.php">register</a><br />
<input type="submit" name="submit" value="Login"  />
</form>
  • 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-22T14:23:25+00:00Added an answer on May 22, 2026 at 2:23 pm

    I believe this is because you’re using change() event rather than live() – as, assuming #cookie is only called into the page after your Ajax event, it doesn’t exist at initial rendertime it can’t bind the change event – checkout live() in the jquery API

    http://api.jquery.com/live/

    UPDATE

    Following your comments I’ve put together the following mock up in JSFiddle, which seems to work.

    http://jsfiddle.net/beardtwizzle/52JQX/2/

    The only error I got during my tests were related to $.cookie – for which you need to include a plugin (http://plugins.jquery.com/files/jquery.cookie.js.txt)

    UPDATE 2

    The problem definitely seems to be down to the cookie setting – try putting an alert('hello world'); in-place of the cookie code and you should see that its getting there – that’s assuming you’re using live(‘change’,function()… rather than bind.

    BUT, thats not your real problem – your real problem is that this method of ‘remember me’ is INSECURE on so many levels.

    1. You are attempting to store a poor visitors password in plain text – which is BAD
    2. When you see a cookie on a user’s machine you’re going to just write out whatever is in there to the value attibute of your fields. By doing this you’re assuming that the user has a genuine cookie from your site – and hasn’t instead injected some of their own malicious code see (http://en.wikipedia.org/wiki/Cross-site_scripting)

    MY ANSWER in light of the above

    My suggestion would be to drop this code ENTIRELY, then go away and read up on web security, then re-address it. If you go ahead and get this working you’re going to hurt innocent users (and damage your reputation badly).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to load my top-menu in a dropdown panel. I used this jquery
I want to load .php files via ajax which execute ExtJS script as they
I load content via Ajax and then I'll have element like $('.my_content_class') and I
I have an update panel load a user control, and the goal here is
I hear a lot about the wrap panel being slower to load things and
I load data into my grid using a WCF service. When a user clicks
I have a page containing a set of jQuery tabs. All the tabs point
I'm using the Colorbox lightbox plugin to display lightboxes with Outside HTML (Ajax) on
I'm trying to load content into a Dojo content pane in a specific html
I'm trying to load in AJAX content into an empty but the div won't

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.