View Full Version : storing variable and putting into link when clicked

08-27-2009, 07:35 PM
hello world,

im attempting to create a script that stores a variable depending on the user logged in (so if user sally is logged in, sally is stored in a variable)

and then swaps that variable with one inside an outgoing link when it is clicked

so if sally clicks somelink.com/?ref=#USERNAME#

the link becomes somelink.com/?ref=sally

08-27-2009, 07:39 PM
how are the usernames stored to start? cookies, mysql, etc?

08-27-2009, 07:44 PM
im not sure yet how to store the username variable in the first place, im trying to find that out right now...

08-27-2009, 07:46 PM
do i need to use mySQL? what i mean is theres no way to have php remember whos logged in after the user changes pages unless the username is stored in the database when they first log in? so then php can grab the variable from the database when they click on links?

08-27-2009, 07:53 PM
you can use cookies http://www.w3schools.com/PHP/php_cookies.asp

08-28-2009, 01:00 AM
i appreciate that link and the info.

ill be doing this inside joomla. so some how i need to edit the built in login module to store the cookie so i can grab it from my link script.

08-28-2009, 01:11 AM
joomla should already store cookies. you have a link? i can get you the cookie name if you dont know how to.

08-28-2009, 12:37 PM
try http://awakedesignstudios.com/ its just a template im using

if joomla stores this cookie of the username, do i need to attach it to a variable, or just call it from php?

how do i get the cookie name?