Page 1 of 1

Make Cookie while Registration

Posted: Tue Jan 29, 2008 1:42 pm
by phreak_02
Hi all,

I'd like to hide a module from users that have been on the "Registration Complete"-Page, but are not yet logged in.

Can this be achieved with a cookie  ?

Thanx for info
phreak

Re: Make Cookie while Registration

Posted: Tue Jan 29, 2008 4:57 pm
by CirTap
Hi,

in 1.5 test for $user->guest - if it's true, the user did not yet login.
$user = &JFactory::getUser();

in 1.0 check the global $my variable.

CirTap

Re: Make Cookie while Registration

Posted: Tue Jan 29, 2008 5:18 pm
by phreak_02
J 1.0.13

I'm writing the cookie in registration.hmtl.php:

Code: Select all

<?php
if(!isset($_COOKIE['mein_cookie'])){
setcookie('mein_cookie','mein_wert',time()+3600,'/');}
?>


and like to call it in the index.php of the template and hide :

Code: Select all

<?php
if(isset($_COOKIE['mein_cookie'])) {
   - - - - - What needs to go here to kill <?php mosLoadModules ( 'left' ); ?> - - - - - }
?>


Thanx for help
phreak

Re: Make Cookie while Registration

Posted: Wed Jan 30, 2008 1:37 pm
by CirTap
Hallo,

you already wrote the code but just need to put the pieces together in the right way:
[php]
if ( isset($_COOKIE['mein_cookie']) ) {
  mosLoadModules( 'left' );
}
?>[/php]
or if you need additional markup in between
[php]


 


[/php]

that's all a bit hackish and you should consider writing a system plugin rather to test for the frontpage (system plugins *also* rn in admin!), the presence of the registration page and the user login status to manage the cookie stuff.

The $user object (still) provides more valuable information, i.e. if the user has regitered, but not activated, last access time etc.
[php]
$user = $mainframe->getUser();
$user->params
$user->name
$user->email
$user->block
$user->sendEmail
$user->registerDate // <--
$user->lastvisitDate // <--
$user->activation // <--
[/php]

Have fun,
CirTap