I made some tests but seems that my server does not maintain info for the sessions.
I used the code taken elsewhere in this forum:
Code: Select all
<?lc
put the globalnames into tOldGlobal
-- don't want to write anything till AFTER session starts or it can cause issues
set the sessionSavePath to the defaultfolder -- saving session stuff to the same dir as the .lc
put "<br>THE DEFAULT FOLDER:" && the sessionSavePath & "<br>"
start session
-- start the session. If you don't do this BEFORE your if check, $_SESSION["counter"] will always be empty
if $_SESSION["counter"] is empty then
put "Fred" into $_SESSION["username"]
-- just added a key to see it work
put 1 into $_SESSION["counter"]
-- using a counter as you were implementing
put merge("Before start: [[tOldGlobal]] After start: [[the globalnames]]")& "<br>"
-- shows the global vars before and after
else
-- if there is a session do the else
put $_SESSION["username"] & "<br>"
-- should put the username defined on the first iteration
put "Session detected: Session counter=" & $_SESSION["counter"] & "<br>"
-- same here, puts the current counter
add 1 to $_SESSION["counter"]
put "Incrementing Session counter:" & $_SESSION["counter"]
-- increments and displays the future counter
end if
stop session
-- this is critical. The changes aren't written out to file if you don't explicitly "stop session"
-- so you end up with session files of 4k with no data.
-- after stop session, file is written, and you're good to go for the next round.
?>
I use Apache 2.2 on Windows.
Livecode cgi works correctly, in fact I can run it. The only problem is SESSION management.
Thank you!