Welcome, Guest. Please login or register.
Did you miss your activation email?
05/23/12, 00:29
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  General
| |-+  General Conversation (Moderators: Flash-db, vesa kortelainen, Ronald Wernecke, Mohsin Sumar, Jorge Solis, Mattias Robo)
| | |-+  how to make a site remember who you are
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: how to make a site remember who you are  (Read 1316 times)
sdfa
Server what's that
*
Posts: 9



View Profile Email
« on: 03/27/02, 02:46 »

Howdy, just want to say that this site has been an invaluable resource to me. I recently started working on a flash site for fun (yes for fun, whats wrong with me=p) anyway decided I wanted to make it dynamic and all that fun stuff with php and mysql.

Anyway here is the deal, I have a flash site which uses php to talk to mysql that people first login to gain access to.  They login and the the information is all querryed from mysql. Once they login to the site I am looking for the best way for the site to remember who they are so that when they access other features of the site they will not need to login again. When they login the input is pased from flash to a php script and the phpscript talks to mysql. each user has a field for username and a field for password with many other fields all in the same row. Id like to have it so that once they login once they can modify fields in their row of the table without having to check their username and password each time. Is there a way for me to automate this setup? For example when someone logs into flash-db it recalls who you logged in as now mater which section of the website you access.
im kinda lost as to which direction i should take from here, any help greatly appricated!!

thanks

j
Logged
Flash-db
Administrator
Systems Administrator
*****
Posts: 1867



View Profile WWW
« Reply #1 on: 03/27/02, 11:25 »

You'll want to use Cookies.

Setting cookies is fairly straight forward,

When someone logs in for the first time (or registers) - you'll want to add something like the following to the script.


setCookie ("UserName",$UserName, time()+30240000, "/");
setCookie ("Password",$Password, time()+30240000, "/");

This will 2 cookies to the users browsers cache.  The format is:

setCookie ("CookieName",ValueToBeStoredInCookie, CookieExperiationDate, "DirectoryWhereCookieIsValid");

The "/" part for where the cookie is valid indicates that the cookie is valid in the top level directory - since cookie validity follows a heirarchy this means that it will be available in all sub directories as well.  

If you set a cookie in a sub directory and don't specify the "/" part of it - it will only be valid in that directory on your server.

To retrieve the value from a cookie all you have to do is in the script have something like

$UserName (The value is automatically set) - So unless you have register globals turned off in your php.ini file that's it.  You can add a check to make sure that it resides in a cookie with something like:

$UserName = $HTTP_Cookie_Vars[UserName];

-------------

In the flash movie you'll have to have a loadVariables function that loads in a script that basically just grabs the cookie vars and brings them into the flash movie.

Alternativly - you can embed your flash movie in a PHP script - then grab the cookie vars from that script and attach them onto the end of the Object Embed .swf?UserName=$UserName... etc part.

Well that's a start anyways.
Logged

-Jeff.
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
anything