Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[java]skipping intro with cookies

Custom Title Activated
Loyal Member
Joined
Nov 28, 2004
Messages
2,236
Reaction score
0
I have been searching google for an example how to set up a cookie so that the user who opens and selects "do not show intro page anymore" box next time he loads is automatically forwarded to without showing intro. The cookie should have expiration (i.e. 24 days)...

If anyone has some spare time and knows java/php you could help me here...

Thanks
 
Custom Title Activated
Loyal Member
Joined
Nov 28, 2004
Messages
2,236
Reaction score
0
should do it
err... what's the use of it if I want to make the page visible/skipable with cookies depening on the viewer's preference...
this is only for including the external page into file, i think...
 
Custom Title Activated
Loyal Member
Joined
Sep 7, 2004
Messages
1,886
Reaction score
5
Well im quite new to PHP because i started 3 days ago but so far i have learnt abit on Cookies. This is the code for a cookie named "Ali" and expires after ten hours.

<?php
setcookie ("ali" , $name, time()+36000);
?>

Now to retrieve a cookie value and redirect to your page.

<?php
if (isset($_COOKIE["ali"]))
echo "Welcome " . $_COOKIE["ali"] . "!<br />";
header("Location:http://www.ali.com");
else
echo "You are not logged in!<br />";
?>

If i am not correct please correct me lol so i learn my mistakes. Hope this helps you [lexx]
 
Custom Title Activated
Loyal Member
Joined
Nov 28, 2004
Messages
2,236
Reaction score
0
Well im quite new to PHP because i started 3 days ago but so far i have learnt abit on Cookies. This is the code for a cookie named "Ali" and expires after ten hours.

<?php
setcookie ("ali" , $name, time()+36000);
?>

Now to retrieve a cookie value and redirect to your page.

<?php
if (isset($_COOKIE["ali"]))
echo "Welcome " . $_COOKIE["ali"] . "!<br />";
header("Location:http://www.ali.com");
else
echo "You are not logged in!<br />";
?>

If i am not correct please correct me lol so i learn my mistakes. Hope this helps you [lexx]
When I come back home, I'll test it.
But as far as see there's nothing about the checkbox.
The user, who enters to intro page and clicks on "never show me" does not see the intro page, and others, who do not click that option next time they enter the site are not auto-redirected to the portal.
 

iod

Custom Title Activated
Loyal Member
Joined
Feb 19, 2004
Messages
1,465
Reaction score
2
Code:
oops
That'd be for the checkbox, abc.php is what you'd point it to (either a file that would set the cookie and then forward to the realsite index or point it directly to real index and just make it add the cookie there).

Code:
if (isset($_COOKIE['skip'])){
header("Location: url");
**else{
( print your index)
**
Put that on the index with the checkbox code, skip would be the name of the cookie to set.
 
Last edited:
Custom Title Activated
Loyal Member
Joined
Mar 9, 2004
Messages
2,425
Reaction score
2
[lexx] said:
err... what's the use of it if I want to make the page visible/skipable with cookies depening on the viewer's preference...
this is only for including the external page into file, i think...

wht i posted was just the first part of it

should learn php. very intresting language~
 
Custom Title Activated
Loyal Member
Joined
Nov 28, 2004
Messages
2,236
Reaction score
0
wht i posted was just the first part of it

should learn php. very intresting language~
i know that. every language is interesting/usefull if you know it well.. :)
Well, I haven't tested the script IOD posted yet. I have some problems accessing my web server. Tomorrow (oh, that's today :)) I will report it.
 
Custom Title Activated
Loyal Member
Joined
Nov 28, 2004
Messages
2,236
Reaction score
0
So did it work out? I know what I posted was a little vague, I'm curious whether you got it working or not.
Oh, I was so busy so I even forgot about this. But I have tested it.
The problem is that I see only the checkbox, I think there should be a submit button, because it is not working.. :)

Since I don't understand the submit system I don't know what to add here...
 

iod

Custom Title Activated
Loyal Member
Joined
Feb 19, 2004
Messages
1,465
Reaction score
2
oops pasted the wrong thing :(

heres what i had before it submits when the box is checked
 

Attachments

You must be registered for see attachments list
Custom Title Activated
Loyal Member
Joined
Nov 28, 2004
Messages
2,236
Reaction score
0
okey, so I have created two files:

test.php:
<html>
<body>
<script type="text/javascript" language="JavaScript">
<!--
function DoSubmit() {
document.skip.submit();
**
//--></script>
<form name="skip" method="post" action="cookie.php">
<input type="checkbox" name="checktest" onClick="DoSubmit();"> Skip the intro
</form>
</body>
</html>

and cookie.php:
<?php
if (isset($_COOKIE['skip'])){
header("Location: site_base/");
**else{
( print your index)
**
>

and when I click "Skip the intro" I see the following error:
Parse error: parse error, unexpected T_STRING in /home/webroot/fknevezis.lt/cookie.php on line 5
 
Custom Title Activated
Loyal Member
Joined
Nov 28, 2004
Messages
2,236
Reaction score
0
okey, so I have set the following in my cookie.php:
<?php
if (isset($_COOKIE['skip'])){
header("Location: intro.php");
**else{
header("Location: site_base/");
**
?>
now when I open test.php ( ) and click "skip the intro" I am auto pointed to site_base/ (that's good) but when I enter test.php again, I see the same page and I should have beend automatically redirected to site_base/ without showint the test.php content...
 

iod

Custom Title Activated
Loyal Member
Joined
Feb 19, 2004
Messages
1,465
Reaction score
2
you didnt add anything to set the cookie, here it is all in one file
 

Attachments

You must be registered for see attachments list
Custom Title Activated
Loyal Member
Joined
Nov 28, 2004
Messages
2,236
Reaction score
0
I know I am starting to pi** you off but it does not work again.
I just copied, pastled everything to test.php (if it works, I will put this into index.php of my site). And I also changed index.php in that script to cookie.php.

But wait a minute. I am not sure now how it would work with two files...

Err, I will include that last code, that you posted here into index.php (my intro page). If the user chooses SKIP INTRO NEXT TIME he is redirected to site_base/ (if not, he has to click hyperlink ENTER THE SITE) and next time when he enters index.php he is automatically redirected to site_base/ without showing intro page...

So I am a bit confused, you see...
 

iod

Custom Title Activated
Loyal Member
Joined
Feb 19, 2004
Messages
1,465
Reaction score
2
k check this out that's all in one file using the script

check the box and you get redirected to site_base then go to again and you'll be redirected automaticly, thats what you want right?

[lexx] said:
I know I am starting to pi** you off
You're not I thought I was starting to piss you off actually.
 

Attachments

You must be registered for see attachments list
Custom Title Activated
Loyal Member
Joined
Nov 28, 2004
Messages
2,236
Reaction score
0
I am including my intro file. When I add the code to my existing intro page I get error...
Check it out.
 

Attachments

You must be registered for see attachments list
Back
Top