note 15899 added to function.session-register

From: Date: Mon, 08 Oct 2001 03:04:25 +0000
Subject: note 15899 added to function.session-register
Groups: php.notes 
Request: Send a blank email to php-notes+get-18668@lists.php.net to get a copy of this message
Hey, Here's a good tip to do a is client-side javascript enabled using session_register (which was a pain to implement!) Ok, on page 1 [index.php] use this following code: <? session_start(); session_unset(); session_unregister('js'); session_unset('js'); //On the main index page, I've unregistered/unset the "js" session as well as all session variables becuase the user may re-enable js for some crazy reason after turing it off, so it's good to check over and over again if they come back to the main page. I tried just to do session_unset() and session_unregister('js'); and it does not work individually, so when I put them all there, it worked - go figure - so use them all! ?> <HTML> <HEAD> <script language="javascript"> location.href="/yoursubfolder/index.php?js=true"; //If the user has js and it's enabled - they should goto page two in the subfolder (or anywhere you want it to go) while registering js=true. </script> <META HTTP-EQUIV="Refresh" CONTENT="0;URL=http://www.yoursite.net/subfolder/index.php?js=false" /> //If they don't have a js browser or it's disabled - use a meta refresh to redirect and register the js session variable to "false" On page two [index.php - on the subfolder redirect] use this code: <? session_start(); session_register('js'); ?> <a href="/site_nav/solutions/index.php<?php echo('?js='.$js); ?>"> //redirect to your "real" start page that you can take steps to include a file that has "html links" as opposed to js links/navs while making sure that the 'js' session variable took from page 1 - which I had problems with until I passed it again to another page [page2 in this case.] This second page was a welcome splash page that would lead into the site which uses js navigation exclusively -so before they go in, I want to make sure that have js enabled, or if they don't, include a file that does have html links. Hope this helps using session_register, esp. when doing a detect script for any client side technology. If you would like to see it in action, take a look at http://www.askasi.net -Alex -- http://www.php.net/manual/en/function.session-register.php http://master.php.net/manage/user-notes.php?action=edit+15899 http://master.php.net/manage/user-notes.php?action=delete+15899 http://master.php.net/manage/user-notes.php?action=reject+15899

« previous php.notes (#18668) next »