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 6762581
In Process

The Archive Base Latest Questions

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

For testing purposes, I want to be able to create cookies as I need

  • 0

For testing purposes, I want to be able to create cookies as I need them.

The cookies I’m using are in this format:
A0A60B1381:ASD887DSFFSDF:SD8F89SD7F89SD7
with any generic name.

I need to read the current values of the cookie if it exists(or create a cookie with that name), split the values into separate input fields, be able to edit those input fields, and write the cookie. (and probably destroy the current value of the cookie, if need be).

What would be the best way to approach this?

UPDATE:

Thanks to Abdullah, I have this code now – however, it isn’t pulling in cookies from other domains. So I need it to pull in the cookie – “junk” from any domain, and write it across domains with a expiration date. How would I do that in this context?

 <script>
        $(document).ready(function() {

        var val = $.cookie('junk');
        var arr = val.split(':');
             $('#Cookie_input0').val(arr[0]); // set value of input element
            $('#Cookie_input1').val(arr[1]); // set value of input element
            $('#Cookie_input2').val(arr[2]); // set value of input element
            $('#Cookie_input3').val(arr[3]); // set value of input element
            $('#Cookie_input4').val(arr[4]); // set value of input element
            $('#Cookie_input5').val(arr[5]); // set value of input element
        $('#Submit').click(function() {
            //recreate arr from input elements
            var arr = [];
            $('input.cookieJr').each(function() {
                arr.push($(this).val());
            });
            // set cookie
            var val = arr.join(':');
            $.cookie('junk', val); // write the cookie back out
        });
        });

    </script>

And

<form name="cookieValues">
    <input id="Cookie_input0" class="cookieJr" type="text" />
    <input id="Cookie_input1" class="cookieJr" type="text" />
    <input id="Cookie_input2" class="cookieJr" type="text" />
    <input id="Cookie_input3" class="cookieJr" type="text" />
    <input id="Cookie_input4" class="cookieJr" type="text" />
    <input id="Cookie_input5" class="cookieJr" type="text" />
    <input type="submit" value="Submit" id="Submit"/>

</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-26T14:22:22+00:00Added an answer on May 26, 2026 at 2:22 pm

    Use jquery.cookie.js:

    $.cookie('the_cookie'); // gets the cookie
    $.cookie('the_cookie', 'A0A60B1381:ASD887DSFFSDF:SD8F89SD7F89SD7'); // sets the cookie
    

    For example:

    var val = $.cookie('the_cookie') || 'A0A60B1381:ASD887DSFFSDF:SD8F89SD7F89SD7';
    var arr = val.split(':');
    arr[0] = "NEW_VAL";
    val = arr.join(':');
    $.cookie('the_cookie', val); // write the cookie back out
    

    Update

    I think you’re trying to edit the cookie on the fly, this should work:

    // after reading cookie as described above, should be inside a $(document).ready()
    $('#ID_OF_INPUT_ELEMENT').val(arr[0]); // set value of input element
    
    // once input element has been set and some 'submit' button clicked
    $('#ID_OF_SUBMIT_BUTTON').click(function() {
        //recreate arr from input elements
        var arr = [];
        $('input.some_class_they_all_share').each(function() {
            arr.push($(this).val());
        });
        // set cookie
        var val = arr.join(':');
        $.cookie('the_cookie', val); // write the cookie back out
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For purposes of testing compression, I need to be able to create large files,
for performance testing purposes I want to take a small XML file and create
For testing purposes I need strings such as: test\x00string I would like to loop
For testing purposes I have this shell script #!/bin/bash echo $$ find / >/dev/null
For testing purposes, I need to share some definitions between Tcl and C. Is
I'm writing a small web server for testing purposes using python, BasicHTTPServer and SimpleHTTPServer.
When I use this code to download this image (only used for testing purposes),
I have an android project with multiple build targets (using ant). For testing purposes,
I want to be able to create a few dozen users, articles (or whatever
I am using an interface (IDataSet) in front of System.Data.DataSet for testing purposes. I

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.