Asked  6 Months ago    Answers:  5   Viewed   262 times

Say I have a website called, and when a specific page of this site is loaded, say page link, I like to set a cookie for another site called, then redirect the user to

I mean, on load of I want to set a cookie for and redirect user to

I tested it, and browser actually received the cookie from, but it didn't send that cookie on the redirection request to Is it normal?

Can we set cookies for other domains?



You cannot set cookies for another domain. Allowing this would present an enormous security flaw.

You need to get to set the cookie. If redirect the user to

The setcookie script could contain the following to set the cookie and redirect to the correct page on

    setcookie('a', $_GET['c']);
Tuesday, June 1, 2021
answered 6 Months ago

You can do a relative redirect:

window.location.href = '../'; //one level up


window.location.href = '/path'; //relative to domain
Friday, June 11, 2021
answered 6 Months ago

You have to set them before anything is outputted

look there: How can I set, get and destroy cookies in Wordpress?

If you are using a theme in function.php

function set_new_cookie() {
    //setting your cookies there
add_action( 'init', 'set_new_cookie');

Your expiration date is 0 so you cookies will be deleted right away look at the php doc:

EDIT: From

If set to 0, or omitted, the cookie will expire at the end of the session (when the browser closes).

You have to set it like this for example :

setcookie("TestCookie", $value, time()+3600);  /* expire in 1 hour */
Tuesday, September 21, 2021
Michał Turczyn
answered 2 Months ago

You should create a new manager for each instance by TCefCookieManagerRef.New(Path) and store the returned reference into some private field of your form. Then you need to return the stored reference to the Result parameter of the OnGetCookieManager event method:

  TForm1 = class(TForm)
    Chromium1: TChromium;
    procedure FormCreate(Sender: TObject);
    procedure Chromium1GetCookieManager(Sender: TObject;
      out Result: ICefCookieManager);
    FCookieManager: ICefCookieManager2;


procedure TForm1.FormCreate(Sender: TObject);
  FCookieManager := TCefCookieManagerRef.New('C:UniquePathToTheCookieStorage');

procedure TForm1.Chromium1GetCookieManager(Sender: TObject;
  out Result: ICefCookieManager);
  Result := FCookieManager;
Monday, October 18, 2021
answered 2 Months ago

I think you could do it this way:

int result = adminClasses.userfunctions.addNewUser(u);

if (result == 0) {
    request.getRequestDispatcher("signupSuccess.jsp").forward(request, response);

It will evaluate the result on the server side and then, depending on the result, will forward to a signupSuccess.jsp page – i.e. the URL will stay the same, but the response will include success page's evaluated content.

Wednesday, November 24, 2021
answered 6 Days ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :