Questions tagged [setcookie]

The setcookie function sends an HTTP cookie to a client.

setcookie() defines a cookie to be sent along with the rest of the HTTP headers. Like other headers, cookies must be sent before any output from your script (this is a protocol restriction). This requires that you place calls to this function prior to any output, including <html> and <head> tags as well as any whitespace.

1196 questions
-1
votes
1 answer

I dont understand why im getting this error in php Array to string conversion

Heres whats going on, I want to make a multilingual websites Array to string conversion error:Notice: Array to string conversion in C:\wamp\www\choose language\language.php on line 12
Cedricle
  • 95
  • 1
  • 5
-1
votes
1 answer

PHP Cookie setlang

I have the following code on settings.php page: define('APP_PATH', realpath(dirname(__FILE__))); define('APP_LANG', APP_PATH . '/lang'); require_once 'Zend/Translate.php'; $locale = isset($_GET['lang']) ? $_GET['lang'] : 'ro'; // default…
-1
votes
1 answer

I want to keep post variables in an array, I want to use these values after submission

function requiredOk() { if (isset($_POST ["NextQuestion"]) && isset($_POST["Question"])) { if (!empty($_POST ["NextQuestion"])) { return TRUE; } else { return FALSE; } } else { return…
-1
votes
2 answers

session_regenerate_id and setcookie on same page in PHP

Ok, so I am working on this login system and of course when the user logs in i regenerate the session id. But after I regenerate my session id i also want to set a token to be stored in a cookie. However I seem to not be able to do that on the same…
just some guy
  • 524
  • 1
  • 4
  • 18
-1
votes
2 answers

PHP- setcookie cannot modify header information

I'm new to PHP, and I tried to research this question but maybe I'm not asking right... I can tell from other posts/instructionals that I can not user header() or setcookie() after printing out HTML... I commented out the header "redirects" - is…
tree
  • 728
  • 3
  • 12
  • 22
-1
votes
2 answers

Setting cookie after POST gives "undefined index" notice

i have a setcookie function in php. i have a jquery dialog with an input field an a submit button. when i type in a postcode in the input field and push submit the postcode is saved in an php cookie. This cookie wil be shown in an input field on the…
Kees Sonnema
  • 5,759
  • 6
  • 51
  • 106
-1
votes
2 answers

setcookie() the cookies are always empty

Not sure what i am doing wrong... $articleid = "test"; $lastviewedarticles = array(); if (isset($_COOKIE["viewed_articles"]) ) { $lastviewedarticles = unserialize($_COOKIE["viewed_articles"]); } if (!in_array($articleid, $lastviewedarticles)){ …
456543646346
  • 973
  • 4
  • 15
  • 22
-1
votes
1 answer

PHP: cookies via path/domain

Is it possible to set the path and domain one time at the beginning of the script and have all future sets conform to the same? From the docs: bool setcookie ( string $name [, string $value [, int $expire = 0 [, string $path [, string $domain [,…
user1032531
  • 24,767
  • 68
  • 217
  • 387
-2
votes
1 answer

set cookie in onether file with `curl_setopt` etc

I'm googling trying to find a solution to my problem. I need to set a cookie in a diferent file and i'm trying with curl_setopt but it doesnt work. Any way the idea is send with PHP the value to set cookie in another page, something like this: …
Pedro Soares
  • 623
  • 2
  • 10
  • 15
-2
votes
1 answer

What does this cookie line mean? (time()+1*24*60*60;)

I have a php code that says this time for the cookie to expire What exactly does this mean? time()+1*24*60*60;
Amir Salar
  • 1
  • 1
  • 7
-2
votes
1 answer

samesite cookie attribute feature is not enabled in php 7.3.8 version

samesite cookie attribute is not enabling on php version 7.3.8? Attribute is enabled on php 7.3.10 version and 7.2.11. PHP 7.3.10 enabled attrbiute usng below code- setcookie('test', 'new', ['expires' => 0,'path' => '/','samesite' =>…
-2
votes
2 answers

Setting cookies when form password is correct

I have a form and when the users enter "Test" it should create a cookie and load the templates using require function. As soon as the cookie is enabled it will display the template. If the cookie expires it will require again the password. In other…
user9402741
-2
votes
2 answers

I want to convert a PHP code to JavaScript

I have a PHP code. Now, I'm building a WordPress site, instead of a HTML/PHP website. And, I've posted a question on the WordPress forum, someone said: You cannot set cookies with PHP in HTML head sections. Cookies must be set before any output…
Luuk F.
  • 11
  • 4
-2
votes
3 answers

PHP - Problem with cookies/setcookie

I'm having problems with the following code: http://pastebin.com/MCkhzQjs This works locally (on localhost) but when I upload it to the server it does not login. I think it is to do with cookies not being sent. The meta refresh is so that the page…
John
  • 11
  • 1
  • 2
-2
votes
1 answer

Remove a div after is clicked

I want to remove the parent of a div after it is clicked and store a cookie "clicked" with value true. I use JavaScript Cookie to store cookie. So I have a blog with adsense and I want to hide my ads to protect from invalid activity after user click…
Jurgen Kruja
  • 57
  • 1
  • 11
1 2 3
79
80