PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Thu Jul 19, 2018 6:40 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 
Offline
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.


Top
 Profile  
 
PostPosted: Tue Apr 17, 2018 3:34 pm 
Offline
Forum Regular

Joined: Fri Sep 05, 2008 3:34 pm
Posts: 527
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

_________________
Hardcore Games Legendary is the Only Way to Play!
Vegan Advocate 16 lbs grain to make only 1 lb meat, water for 6 months of showers and 34.1 lbs carbon dioxide
My sites are made with WordPress, which is a content management system which now accounts for more than 60% of all websites


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

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13569
Location: New York, NY, US
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.

_________________
(#10850)


Top
 Profile  
 
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: No registered users and 14 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