PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
It is currently Sat Oct 24, 2020 10:21 am

All times are UTC - 5 hours

Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: passing cookie variables
PostPosted: Thu Apr 12, 2018 11:31 pm 
Forum Newbie

Joined: Thu Apr 12, 2018 11:28 pm
Posts: 1
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.

PostPosted: Tue Apr 17, 2018 3:34 pm 
Forum Regular
User avatar

Joined: Fri Sep 05, 2008 3:34 pm
Posts: 539
Location: Victoria, BC
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

PostPosted: Wed Apr 18, 2018 10:12 pm 
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13592
Location: New York, NY, US
Read the manual about cookies:

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


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours

Who is online

Users browsing this forum: Google [Bot] and 29 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group