Make Cookie while Registration

Discussion and education for beginner / novice programmers interested in embarking on the development process to take advantage of the extensible nature of the Joomla! CMS.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Forum rules
Post Reply
User avatar
phreak_02
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Tue Aug 23, 2005 3:31 pm
Location: Austria
Contact:

Make Cookie while Registration

Post by phreak_02 » Tue Jan 29, 2008 1:42 pm

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
http://www.cycomsplat.com - I work for you !
http://www.kindaktuell.at - I'm running this !

User avatar
CirTap
Joomla! Intern
Joomla! Intern
Posts: 73
Joined: Mon Dec 12, 2005 5:34 pm
Contact:

Re: Make Cookie while Registration

Post by CirTap » Tue Jan 29, 2008 4:57 pm

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
You can have programs written fast, well, and cheap, but you only get to pick 2 ...

"I love deadlines. I like the whooshing sound they make as they fly by." Douglas Adams

User avatar
phreak_02
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Tue Aug 23, 2005 3:31 pm
Location: Austria
Contact:

Re: Make Cookie while Registration

Post by phreak_02 » Tue Jan 29, 2008 5:18 pm

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
http://www.cycomsplat.com - I work for you !
http://www.kindaktuell.at - I'm running this !

User avatar
CirTap
Joomla! Intern
Joomla! Intern
Posts: 73
Joined: Mon Dec 12, 2005 5:34 pm
Contact:

Re: Make Cookie while Registration

Post by CirTap » Wed Jan 30, 2008 1:37 pm

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
You can have programs written fast, well, and cheap, but you only get to pick 2 ...

"I love deadlines. I like the whooshing sound they make as they fly by." Douglas Adams


Post Reply