persistent variable / calendar user-group

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
johncc
Forum Newbie
Posts: 2
Joined: Thu Jan 29, 2009 8:51 pm

persistent variable / calendar user-group

Post by johncc »

Let me say at the outset that I am fairly new to PHP.

I am modifying a calendar script which has multiple adminstrators who can edit their own entries. I would like to give an associated group of users access so that they only see the entries of one of the admins. (Later on I hope to expand it so that a particular user can view the entries of several admins.) I can display the calendar correctly based on the value of a variable ($group), but what I can't figure out is how to make $group variable persistent. I don't want users to be able to access other calendars unless permitted by the script. That means that I can't use the xxxx.php?group=3 type of mechanism.

I am setting $group in a user specific page in which session_start() is called and then calling the original code. The trouble is that session_destroy() is called a few times, so I lose my value.

Would this be an appropriate case for a cookie and if so is that secure? What other mechanisms whould you suggest?

Thanks for any help.
johncc
Forum Newbie
Posts: 2
Joined: Thu Jan 29, 2009 8:51 pm

Re: persistent variable / calendar user-group

Post by johncc »

Answering my own question.

It appears that my solution is to use a $_SESSION[] variable, but I did not realise that I need to use SESSION_START() on each page. I was able to remove the SESSION_DESTROY() by specifically UNSET ing the session variables that the destroy was aimed at while retaining my 'group' variable.

Hope that helps somebody.
Post Reply