PDA

View Full Version : setting php session var from flash


Billy T
01-25-2005, 10:21 AM
Hey all

thought this was straight forward but maybe not

at the top of the page that embeds my flash movie I have

<?php
session_start();
header("Cache-control: private"); //IE 6 Fix
if(!isset($_SESSION['loggedIn'])){
$_SESSION['loggedIn']='no';
}
?>

I was then then hoping to manipulate the value of that session variable via flash using the LoadVars object

ie

//bunch of other stuff
if($username!=-1){
//set var
$_SESSION['loggedIn']='yes';
//send result back to flash
echo "&result=success&username=$username";
}else{
echo "&result=error&errorMessage=Could not retrieve your username";
}


doesnt seem to be working though - am I missing something?

Thanks

Billy T
01-25-2005, 11:04 AM
this is very odd...

Please someone put me out of my misery

if you go here you will see

http://www.designbynature.org/testing/main.php

at the top of that page I have the code from the previous post

down the bottom I have

<?
echo "&loggedInStatus=" . $_SESSION['loggedIn'];
?>

which echos the correct value.

If you click on manifesto it loads a new movie. in that I have this code


function checkLoginStatus() {
loggedInlv = new LoadVars();
loggedInlv.onData=function(raw){
test_txt.text=raw;
}

loggedInlv.sendAndLoad(_root.prefix+'scripts/checkLoginStatus.php?clearcache='+Math.random()*50 00, loggedInlv, 'POST');
}
checkLoginStatus()


checkLoginStatus.php is simply this

<?
if(!isset($_SESSION['loggedIn'])){
echo "&loggedInStatus=session var not set";
}else{
echo "&loggedInStatus=" . $_SESSION['loggedIn'];
}
?>

As you can see from the output back in flash, it thinks the variable hasnt been set. Surely this doesnt have anything to do with the code being in an external movie?

Stumped and hot :(

Thanks

Billy T
01-25-2005, 01:17 PM
needed

session_start();

on every file...

CyanBlue
01-25-2005, 02:58 PM
You just needed a cup of coffee... ;)

Billy T
01-25-2005, 03:00 PM
opposite actually - need sleeeeep

been playing world of warcraft...very addictive