Page 1 of 1

passing cookie variables

Posted: Thu Apr 12, 2018 11:31 pm
by davidpiter98
Hi guys,

An authentication script which then extracts the user id entered by the user and then stores it in a cookie variable called $mycookie.

Further on into the site I am able to use the cookie to perform various select statements. Only problem is that php files that i have 'required' do not recieve or even recognise the $mycookie variable.

example: require("add.php");

So my select statements which end WHERE user_id='mycookie' simply do not function.

Please forgive me if im overlooking something very small, please point me in the right direction.

Many thanks.

Re: passing cookie variables

Posted: Tue Apr 17, 2018 3:34 pm
by Vegan
usually cookies are done with JavaScript which then calls some PHP code on the web server to update the database that a cookie has been set etc

you will discover that there is a lot of interaction back and forth with PHP and JS

Re: passing cookie variables

Posted: Wed Apr 18, 2018 10:12 pm
by Christopher
Read the manual about cookies: http://php.net/manual/en/features.cookies.php

Get cookie values in PHP from the $_COOKIE global. Use the setcookie() and setrawcookie() functions to set cookies.