Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Feb 19th, 2008, 12:47 AM   #1
MrMan9879
Programmer
 
MrMan9879's Avatar
 
Join Date: Sep 2005
Location: Nanaimo, BC, Canada
Posts: 96
Rep Power: 0 MrMan9879 is an unknown quantity at this point
Send a message via MSN to MrMan9879
Sessions Problem

I'm trying to learn more about PHP sessions, as I'm going to be using them in a website I'm building soon.

Anyways, my problem with them is that I'm wondering how I can make them last after the user's browser is closed.

Here is a code example:

<?php
start_session();

$_SESSION['name']='Andrew';
$_SESSION['country']='Canada';
$_SESSION['age']=16;

?>

Then obviously I would view the session on another page with code like this:

<?php
start_session();

echo $_SESSION['name'];
//and so on

?>

Now, as I understand it... sessions are stored in a cookie on the user's browser so that other scripts can use them and such. The above code always works, and I can go to another page and come back and it still works. But, if I close my browser and I come back to the page that views the session variables, they aren't set anymore.

I've tried changing settings like session:cookie.lifetime, session:cookie.expire, etc. but so far, I've pretty much had no luck. I've searched with google thoroughly and checked the PHP manual, and I haven't found anything that's helped me out.

So, anyone have anything that'll help me out? Basically, I'm going to be using sessions with MySQL for authentication and such, so I figured it would be nice to have users logged in when they come back after closing their browsers. I assume this is possible, as I've seen it before, but perhaps the websites were using something different?

Last edited by MrMan9879; Feb 19th, 2008 at 12:48 AM. Reason: punctuation error
MrMan9879 is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Challenging Programming Problem - "Pinball Ranking" Sane Coder's Corner Lounge 38 Jan 15th, 2008 5:16 PM
Problem solving ReggaetonKing Software Design and Algorithms 7 Jan 4th, 2008 1:49 PM
Storing BLOBs in a database - problem jonyzz Other Programming Languages 8 Jan 31st, 2007 4:38 AM
Changing icons problem Pedja C# 8 Mar 25th, 2006 8:03 AM
cgi/perl script + IE problem joyceshee Perl 2 Jan 24th, 2006 11:10 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:48 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC