Login     Sign up
building a mod question
Dann (@zipp2000)
Join date: Sep 17th 2010
Community posts: 28
View Profile
Send Message

I'm building a huge mod I want to stop access to the page unless user is not loged in.

I'm using below code on page load but it can still let users in after user logs out. Seems Jcow's sessions don't fully clear on logout, is there another way to check if user is loged in without setting private settting in admin?

[code]
session_start();

if (!array_key_exists('uid', $_SESSION)) {
header('Location: [url]http://www.site.com);[/url]

}
else {

}
[/code]

166 months ago
Jcow Master (@falcone)
Join date: Sep 2nd 2010
Community posts: 917
View Profile
Send Message

if you make a module and you set it to protected, a not logged in user (guest) cannot access this module.

example the browse module.

in browse.install.php

function browse_menu() {
$items = array();
$items['browse'] = array(
'name'=>'Browse',
'type'=>'community',
[b]'protected'=>1[/b]
);

return $items;

}
then in admin/permissions you have to check general member to allow a logged in user to access your module.

166 months ago
Mohammad Emran (@monemran)
Join date: Sep 15th 2010
Community posts: 28
View Profile
Send Message

You can use need_login() in the starting of index()function...like this:

[code]
function index(){

need_login()
......
........
........
}
[/code]

166 months ago
Dann (@zipp2000)
Join date: Sep 17th 2010
Community posts: 28
View Profile
Send Message

thanks all for help i got it in end i left session on gaming mod wich i added for you all here to use

http://community.jcow.net/forums/viewthread/474

166 months ago