Hello all,
I would like to use a cookie in my web design. I have located the put cookie command in the LiveCode dictionary. I understand the syntax but I am having trouble figuring out where to place the put cookie command in my .lc file.
The documentation says that the command has to be prior to any header command. I have placed my command just after the <html> tag with no success.
<html>
<head>
<title>
my little slice of heaven
</title>
</head>
<body>
</body>
</html>
Can anyone share a few lines of code showing the proper context for put cookie usage.
Regards, Rocky Heuft
using set cookie
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: using set cookie
You need to use cookies functions before... anything else.
At the top of your .lc file.
Example :
At the top of your .lc file.
Example :
Code: Select all
<?lc
set the errorMode to "inline"
put $_COOKIE into tCookie
put tCookie["myCookie1"] into tCookie
if tCookie is empty then
put new header "Location: index.lc?C=1"
put "Sorry..."
quit
end if
put char 1 to 2 of $_SERVER["HTTP_ACCEPT_LANGUAGE"] into tLanguage
put $_POST["email"] into tEmail
include "../includes/fonctions.lc"
?>
<html>
<head>
<title>
my little slice of heaven
</title>
</head>
<body>
</body>
</html>
-
- Posts: 5
- Joined: Thu May 11, 2017 7:19 am
Re: using set cookie
Hello and thank you.
I have tried to put my Cookie coding at the top of my file with no luck.
I do not have an ../includes/ folder on my system. Is that part of some extra install process?
Regards, Rocky Heuft
I have tried to put my Cookie coding at the top of my file with no luck.
I do not have an ../includes/ folder on my system. Is that part of some extra install process?
Regards, Rocky Heuft
Re: using set cookie
No it was just to show you what can be done.RockyHeuft wrote: ↑Fri Sep 18, 2020 5:44 amI have tried to put my Cookie coding at the top of my file with no luck.
I do not have an ../includes/ folder on my system. Is that part of some extra install process?
So, I guess your problem comes from the script that writes/creates the cookie.
You need to check this. What is your script ?
One tip : create 2 news lc files. With simple content inside.
the first one : where you create the cookie (it will act like your "index" page, where your user arrives when he connects to your site)
the second one : where you read the cookie (and perform some verifications)
And then play with those 2 files, to see the interactions.
-
- Posts: 5
- Joined: Thu May 11, 2017 7:19 am
Re: using set cookie
Hello and good day.
I tried it again with a very simple page. I now can get set cookie to work properly.
Thank you for your help.
Regards, Rocky Heuft
I tried it again with a very simple page. I now can get set cookie to work properly.
Thank you for your help.
Regards, Rocky Heuft