PHP Developers Network

passing cookie variables
Page 1 of 1

Author:  davidpiter98 [ Thu Apr 12, 2018 11:31 pm ]
Post subject:  passing cookie variables

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.

Author:  Vegan [ Tue Apr 17, 2018 3:34 pm ]
Post subject:  Re: passing cookie variables

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

Author:  Christopher [ Wed Apr 18, 2018 10:12 pm ]
Post subject:  Re: passing cookie variables

Read the manual about cookies:

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

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group