homepage Welcome to WebmasterWorld Guest from 54.205.52.110
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PHP Sessions
Best way to keep track of users
wfernley




msg:1291480
 5:20 pm on Jan 25, 2005 (gmt 0)

Hello everyone,

I am building a members section for my site and I was curious what the best way to go about remember users would be. The site I'm working on is mainly an information site which will have the ability for people to login and view reviews on products and also allow manufacturers to login and upload information about their products.

I was curious how I should remember a user is on my site. Currently, I have a $_SESSION[''] variable that remembers them but when they open a new browser it forgets them. Also this posses problems if they are still viewing my site but want to have 2 browsers open while on my site.

Is this the best method? Also considering they login - they will have to relogin everytime they come back to my site. This makes me wonder if I should use cookies. I have never used them before. Would they be the best solution? Are they secure?

Any information would be great :)

Thanks!

Wes

 

jusdrum




msg:1291481
 5:31 pm on Jan 25, 2005 (gmt 0)

This is because your sessions are expiring on closing the browser. You can set the session lifetime with ini_set():

ini_set('session.cookie_lifetime',(3600*24*365)); // makes cookie good for a year

One problem with that is the server's temp directory might get clogged with saved sessions. If you have a high traffic site, this could cause problems. You can either use cookies, or make the cookie lifetime something like 30 days.

See [php.net...] for more information.

Hope this helps!

jpjones




msg:1291482
 5:44 pm on Jan 25, 2005 (gmt 0)

One problem with that is the server's temp directory might get clogged with saved sessions

If this is likely to become a problem - you could always set a custom session handler and write everything into a database :)

http://uk.php.net/manual/en/function.session-set-save-handler.php [uk.php.net]

Cheers,
JP

jusdrum




msg:1291483
 7:01 pm on Jan 25, 2005 (gmt 0)

Awesome JPJones, I didn't know you could do that. Good tip.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved