+1  A: 

The first parameter of setcookie is the cookie name and the second the cookie value. So in this case $_SESSION['lang'] is the cookie name and time() + (3600 * 24 * 30) the value:

setcookie($_SESSION['lang'], time() + (3600 * 24 * 30));
Gumbo
@Gumbo I do have setcookie($_SESSION['lang'], time() + (3600 * 24 * 30));
janoChen
@janoChen: Yes, and that’s the point. You didn’t specify the cookie name. Or to be more specific: You specified the value of `$_SESSION['lang']` as cookie name and the value of `time() + (3600 * 24 * 30)` as cookie value.
Gumbo
@Gumbo, I think you are right, I had to specify the name "lang". this worked: setcookie("lang", $_SESSION['lang'], time() + (3600 * 24 * 30));Thanks
janoChen
Hmm... wonder if I'm invisible or something. :-)
middaparka
+1  A: 

The args to setcookie are as follows:

bool setcookie ( string $name [, string $value [, int $expire = 0 [, string $path [, string $domain [, bool $secure = false [, bool $httponly = false ]]]]]] )

As such, the way you're using it seems a little odd. (It's not incorrect that said.) I'd have thought that something like...

setcookie('lang', $_SESSION['lang'], time() + (3600 * 24 * 30));

...would be a bit more obvious, and is perhaps what you're after. (This is what $_COOKIE['lang'] will require.)

middaparka
@middaparka Haha sorry, my mistake.
janoChen