Session handling ok- but no browser being used??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kraiklyn
Forum Newbie
Posts: 1
Joined: Wed Oct 08, 2003 5:39 am

Session handling ok- but no browser being used??

Post by kraiklyn »

Hi,

I have two scenarios and one php page as a test.

The php page just calls session_start() and returns back the session id created/retrieved in the response, very simple.

The first is to make a request to this one php page via a browser and hit refresh, as I would expect the same session id on each refresh, close the browser ( all windows that may be open ), do the same again and I get another session id, which is consistant between refreshes. As you would expect.

The second scenario is to call the same url through flash running as a projector ( no browser need be running ), or from any language tool capable of socket communication. When this approach is taken, the php page still returns a consistent session id throughout each request made.

The problem is, I can get my head around the first scenario, as i know that there is cookie information embedded in the response header that the user agent uses and php will use that in turn to retrieve the proper session from the information in the cookie.

How does php know to retrieve the session when scenario 2 is in place. I am assuming here that because im not using a browser, no cookie information can be used in this context, but still manages to get at the same session. I was also assuming that cookies are only associated with browsers.

Can anyone help, TIA

Rob
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

i am no expert on php and flash put together but don't you think when you access a webpage with a flash movie it would go to that page as a user? to do that it would need some sort of browser to read whats on that page...

make sense? :roll:
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

there's something called flash remoting...

im interested in this. trying to figure out how i can make user authentication thorugh flash, and have something like sessions..
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

i made something like this a while back, it was a feed back form in flash, it would pass its values to php and thenphp would send the email...

you may wanna start here http://www.flashkit.com/tutorials/Dynamic_Content/
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

yes, but, make interaction with php is not so tuff...

what i was trying to do is a client side application, login, db access and stuff.. but for that i need the user "signed in".

Whit php, html frontend,.. its no problem, because i can use sessions or cookies.. but it i dont have a browser???... 100% flash..

how can i do that? how do flash and php mantain a session without the browser?

By the way.. i im not very skilled in flash...
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

hmm..you want to run php code on client side?...ur quite adv, so i am not gona say php is a server side lang..oh wait..i just did :lol:

anyways, you could make a flash movie to access a remote file with vars e.g. access

http://www.somesite.com/flashinfo.php?u ... ass=blabla

if username and pass is correct you return some sort of ID which is also placed in a db table, then pass it back to flash like

Code: Select all

&ID=sdkf4534
&otherstuff=bla bla bla bla bla bla bla
then every time you need to get new content from the site, you just send the ID back, if it is still in the DB then its a vaild user otherwise...its not :)

flash can read information from page with above example..but i think you know that.

am i off track? not really sure what you have in mind...maybe you can show a example? :?
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

jeje

Post by AVATAr »

i dont want to run php on client side...

i algo know how to read a page... (post get stuff)..

let me explain a bit.

supose, i have for example, a Content Management system... but i want that the users can add contect with FLASH a client (could be JAVA, VB, Delphi..).

In this scenario i need user authentication... in html + php y make it with sessions and cookies... but in flash... (swf file).

i can make a form in flash and submit the data to a php file and then to a mysql DB... but how can i handle autentication if i dont have a browser??



PS: sorry kraiklyn i stole your post! :D :wink:
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

how about this then:

you have 3 boxs in your swf movie,

Code: Select all

Username : ї               ]
password: ї                 ]
Content: ї                  ]
right?..ok, all the user does is enter his username, password and the content he wants to submit, on submit, call a page with post or get function in flash and send these values, when it gets there, first check to see if the user has account with your system, if he does then allow the content field data into db,
and output

&msg=Data has been accepted.....

if the user does't have account then return

&msg=YOu dont have a account with us...

make sense?

u can have any number of boxs in the movie, this i sjust a example :roll:
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

it make sense... but its not the main issue here...

ok yout have the login procedure done...

how do you proceed.. in html+php.. you set a cooki or a session variable that you can check to know if the user is authenticated...

but.. how do you do that in flash??? without any browser??? only with the swf???

the interaction of flash with php is not the main problem here...


the interesting thing is how can i create a sesion (socks???..) between a swf (or any other client) and my backend application. ITs like a webservice, but with a full aplication.
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

qads wrote: if username and pass is correct you return some sort of ID which is also placed in a db table, then pass it back to flash like

Code: Select all

&ID=sdkf4534
&otherstuff=bla bla bla bla bla bla bla
then every time you need to get new content from the site, you just send the ID back, if it is still in the DB then its a vaild user otherwise...its not :)
would't this work...cos you have a var in the flash movie acting out as a session cookie. all you have to do is to make sure you don't lose this var somewhere in you movie....i think it would work, if i get some free time i am gona build it just to see if it works :D

(lol..post hijacking is not allowed here you know :lol: )
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

maybe.. maybe its a bit "forced" but could work.. lets try it!!! jeje..
Post Reply