Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need some php manipulation done.

Status
Not open for further replies.

sakaturu

Technical User
May 2, 2001
3
US
I need some manipulation done in php programming that I have and I like it to call it name like welcome "name" and also activate my site with cookies like giving them option on how long they want to stay loged-in "always,8hour,1 month,or never".
thanks
shawn
 
This is generally a simple task.

Once your user has logged and while you are still in the login process (keep in mind that the cookie set below is the most rudimentary cookieset available. For more controls, such as security levels, paths, etc. you should read further (or just ask and I will be more than happy to write a faq for you)):

//session only
$exp = time();

//8 hours
$exp = time() + (60*60*8);

//1 day
$exp = time() + (60*60*24);

//'forever' (cookies cannot be stored forever, all cookies have to expire and typically they only last for 1 year)
$exp = time() + (60*60*24*365);

//set your cookie
setcookie("my_session[0]",$name,$exp);

Now on your pages, you just do something like:

if($my_session) {
//yell hello!
echo "Hello, ".$my_session[0];
}
else {
//inform user they should login to experience
//the best level of options, etc.
echo "You are not logged in...";
}


That is it!

The cookie automatically expires, thus after say 8 hours which I chose to remain logged in, I will receive the "you are not logged in... " stuff instead of my welcom message.

This can also be extended to limited functionality on your site (restricted areas, etc).

Hope this helps.

Chad.
 
Hi Chad
Thanks for getting back to me.
is it possible to have a check boxes like A,B,C,D
A=always
B=8 hour
C=1 month
D=never
on the sign up page? and also in there profile when ever they want to change it as well?
and what about name calling like "Hi Shawn" come up on any pages on my site? pages have to be in php?
Do you do work on the side? and how much you charge?
thanks
 
Sakaturu,

What you want is definitely possible but you would use radio buttons, not checkboxes for this option.

Users can definitely modify their preferences just by updating the cookie, which would start the 'timer' over again.

It would be preferable to use PHP for ultimate control, but you can use any language to access these cookies such as Perl or Javascript.

I do in fact do consulting/development work on the side and typically charge $35.00 per hour for standard design/development work (PHP, Perl, MySQL, C, etc.). I am always flexible and if you need help with your project, I am sure I can swing time for you at a very minimal charge or even at no charge depending on what you want done.

You can send me an email at chorton@inlandpac.com to send me information of what you would like done. I usually get back within a couple of hours or sooner.

Sincerely,
Chad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top