Sessions on XAMPP no go, Live ok.[Headache]

Are you using LiveCode to create server scripts or CGIs?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Sessions on XAMPP no go, Live ok.[Headache]

Post by sphere » Sun Nov 03, 2019 4:02 pm

Hi,

this piece of an .lc file works ok on real server but not local on XAMPP

Code: Select all

<?lc
set the sessionSavePath to the defaultfolder
set the sessionLifetime to 1800
set the sessionCookieName to "LCTESTCOOKIE"
set the sessionID to "SessionTestIdentifier"
start session
--empty when return to page
if $_SESSION["place"] is not empty then
put empty into $_SESSION["place"]
end if
if $_SESSION["name"] is not empty then
put empty into $_SESSION["name"]
end if
stop session
?>
on XAMMP it gives an error in the browser like:
file "D:/server/xampp/htdocs/testlc/lc_place.lc"
row 8, col 1:
and as i read in a few messages on the list and on the forum here, it is probably that a folder is not existing or it has no rights to write there.
I also tried this: set the sessionSavePath to "/sessiontemp" , an extra created folder with the correct rights but no go.
Also tried the complete path like: D:/server/xampp/htdocs/testlc/sessiontemp

Anyone know how to fix this in XAMPP so i can develop LOCAL instead of on live server?

Thanks a lot!
Last edited by sphere on Sun Nov 17, 2019 3:58 pm, edited 2 times in total.

ghettocottage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 366
Joined: Tue Apr 10, 2012 9:18 am

Re: Sessions on XAMPP no go, Live ok.

Post by ghettocottage » Sun Nov 03, 2019 11:29 pm

have you tried (just for debugging) to set the folder permissions to 777, or whatever the windows equivalent of the is (writable by everyone)

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Sessions on XAMPP no go, Live ok.

Post by [-hh] » Sun Nov 03, 2019 11:31 pm

On most OS opening a local file with a browser doesn't work any more.
You have to put the file into htdocs (=your web folder) or a 755 folder of htdocs and call it as webpath.

Say 8080 is the port at which XAMPP listens and "localhost:8080" is the serverName, then "/" is the top of the webpath, replacing "D:/server/xampp/htdocs/" in your case.

In sum, you could try as URL: localhost:8080/testlc/lc_place.lc

You can change the port and serverName in the XAMPP control panel in "Config Apache (httpd.conf)".
Of course XAMPP should be configured (as the remote server is) to run LC Server.
shiftLock happens

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Sessions on XAMPP no go, Live ok.

Post by sphere » Mon Nov 04, 2019 1:39 pm

Thanks.

Yes the folder is write-able for everyone.
lc_place.lc is located in the folder testlc under htdocs in XAMPP.

The URL in the browser which i open is localhost:80/testlc/lc_place.lc

The error is then displayed in the browser screen.

row8 column1 is where the command start session resides.

Maybe it is a rights issue, but maybe one that xampp when running does not see as it's own, although when checking in windows it is writable.
Will google a bit.

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Sessions on XAMPP no go, Live ok.

Post by sphere » Mon Nov 04, 2019 3:03 pm

Just tried it on another PC there the defaultFolder worked right away.

Added another folder to store the sessions and got the same error.
Now i checked the permission of this folder and changed it for the current user
folder.JPG
And added this in the lc_place.lc file
set the sessionSavePath to "C:/Portable/xampp/htdocs/lc/session"

And it works!

Is it correct that this is neccessary in each file or only the first time, say with the index.lc page?:

Code: Select all

<?lc
set the sessionSavePath to "C:/Portable/xampp/htdocs/lc/session"
set the sessionLifetime to 1800
set the sessionCookieName to "LCTESTCOOKIE"
set the sessionID to "SessionTestIdentifier"
Thanks!

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9801
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Sessions on XAMPP no go, Live ok.

Post by FourthWorld » Mon Nov 04, 2019 4:34 pm

sphere wrote:
Mon Nov 04, 2019 3:03 pm
Is it correct that this is neccessary in each file or only the first time, say with the index.lc page?:

Code: Select all

<?lc
set the sessionSavePath to "C:/Portable/xampp/htdocs/lc/session"
set the sessionLifetime to 1800
set the sessionCookieName to "LCTESTCOOKIE"
set the sessionID to "SessionTestIdentifier"
A CGI is initialized, runs, and terminates with reach HTTP request. Any changes to global properties will die along with the process.

Within a given request, you should only need to set that path once, no matter how many other scripts are invoked before the process dies.

But you will want to have any initialization your scripts need performed with each request.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Sessions on XAMPP no go, Live ok.

Post by sphere » Mon Nov 04, 2019 6:34 pm

Ok thank you Richard.

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Sessions on XAMPP no go, Live ok.

Post by sphere » Tue Nov 05, 2019 9:44 pm

Very strange, yesterday sessions on localhost worked, today not. Nothing has changed.
On live host still working. Can't comprehend...

ghettocottage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 366
Joined: Tue Apr 10, 2012 9:18 am

Re: Sessions on XAMPP no go, Live ok.

Post by ghettocottage » Wed Nov 06, 2019 4:07 am

A raspberry pi with Ubuntu 18.04 server would make a nice little LC Server Development Box:
https://www.adafruit.com/product/4295?src=raspberrypi

mrcoollion
Posts: 709
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Sessions on XAMPP no go, Live ok.

Post by mrcoollion » Wed Nov 06, 2019 7:50 am

One can also use uWAMP for Windows which is a free Wamp Server with Apache MySQL PHP and SQLite.
It works really easy because it is a portable version that needs no installation and has a nice startup interface. I used it e.g. to test OpenSource iTOP ITSM Software and it runs excellent.

Info at: https://www.uwamp.com/en/
Download url https://www.uwamp.com/en/?page=download

Unzip/URAR or install (depends on what package you downloaded) and run UwAmp.exe (use admin privileges to be sure).
place your web app in the .../www/my-app/ folder.
use the UwAmp interface for setting up PHP and MySQL.

IMPORTANT Prerequisites !!
Before using UwAmp you must install Visual C++ Redistributable x86 version vc_redist.x86.exe. This is a PHP requirement.
This is also available at https://www.uwamp.com/en/?page=download

Regards,

Paul

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Sessions on XAMPP no go, Live ok.

Post by sphere » Wed Nov 06, 2019 9:22 am

Would a raspberry be faster then the VPS i now run?
It works ok on VPS just not on Localhost, but indeed i could use it as fake (real) server.

I will take a look at WAMP, previously i used EasyPHP, also a nice package and in the past i installed all module one by one on windows. But a single install is easier.

I'm now rewriting the PHP pages i have working to LC.
I also had the idea to just use the existing PHP pages and use only the last page with LC-server. But probably this is more difficult the to use first sessions from PHP and then switch to LC.

For now i need to get this sessions running stable so i can continue develop LOCAL instead of uploading each adjustment to the live server and test there.

Thanks for your suggestions.

ghettocottage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 366
Joined: Tue Apr 10, 2012 9:18 am

Re: Sessions on XAMPP no go, Live ok.

Post by ghettocottage » Wed Nov 06, 2019 4:40 pm

Would a raspberry be faster then the VPS i now run?
Most likely, with the added benefit of being an always-on local server that could be used for other various tasks or projects (plex server, file server, etc)

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9801
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Sessions on XAMPP no go, Live ok.

Post by FourthWorld » Wed Nov 06, 2019 5:49 pm

Is your VPS running Windows or Linux?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Sessions on XAMPP no go, Live ok.

Post by sphere » Wed Nov 06, 2019 6:14 pm

Thanks gettocottage will think about it.

It's a starters vps with just one core and 50GB. I have Linux running ubuntu 18.04.
And for dev localhost i use Xampp on Windows.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9801
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Sessions on XAMPP no go, Live ok.

Post by FourthWorld » Wed Nov 06, 2019 6:30 pm

Even if you use Windows for development, one nice thing about ghettocottage's suggestion of having a cheap local Linux server is it provides a staging server that more closely mirrors your production server.

You don't want to discover something like a case sensitivity issue in production. ;)

You can set up shared ssh keys and use rsync to push from that staging server to the production server, faster and less error-prone than manual updates.

Bonus that you can also put it to use providing other services for your local network. I use one here with Nextcloud to keep my LC plugins and client work files in sync across the machines I develope and test on, and in its spare time it gathers and packages up the various data sources displayed in LiveNet.

Small cheap machines like nettops or Pi are great for always-on services because they consume just pennies' of electricity over the course of a year. And they're fun. :)
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “CGIs and the Server”