Page 1 of 1

Controling sessions

Posted: Mon Jan 19, 2004 1:11 pm
by mzfp2
Hi

Ive just switched to using sessions for my login system, however I find that (and my users) that while navigating between pages, or different windows, the session is lost and a re-login is required.

I was wondering if it is possible to start a session for a fixed period of time?

http://www.alljammin.com -Free funky dating and flirting

Posted: Mon Jan 19, 2004 1:13 pm
by malcolmboston
you are using

Code: Select all

session_start();
on every page right?

Posted: Mon Jan 19, 2004 1:26 pm
by mzfp2
Yeah I am, every page includes a file called my_session.php which has session_start() in it

Posted: Mon Jan 19, 2004 2:11 pm
by patrikG
This thread deals exactly with your problem:

http://www.devnetwork.net/forums/viewtopic.php?p=53693

Posted: Mon Feb 23, 2004 2:54 pm
by Magosoft
Ok, every I have done everything in the thread, but.
I'm developing a page with Apache 1.3.X and php-4.3.4,
under Windows 2000 professional.

In my php.ini file I had set the session_path="C:\php\sessions"
when I start the session with:

<?php
session_start();
$_SESSION['myvar]='Some string';
echo '<a href="test.php">Test</a>';
?>

This creates a file with the name:
sess_56#######.....etc.
When I edit it is says:
myvar|s:11:"Some string"
However, when I hit the Test link on my page
the value does not exists in the new page, and
it creates me a new session file in the session folder.

The code for the test.php file is:
<?php
session_start();
echo $_SESSION['myvar'];
?>

Any help will be appreciated.

MAGO

Maybe this can help you?

Posted: Tue Mar 02, 2004 8:18 pm
by cyberhawk
I had the same problem, check your php.ini and locate this:

session.use_trans_sid = 0

and change the 0 to 1:

session.use_trans_sid = 1

Then reboot your puter.

And then your script will work, promise.

And 4 some code, have a look at my little test.

First page

Code: Select all

<?php 
session_start(); 

$un = "anders"; 

$_SESSION['uname']=$un; 
$_SESSION['ualias']='olle'; 
echo '<pre>'; 
print_r($_SESSION); 
echo '</pre>'; 
?> 

<p><a href="test4.php">Page 2</a></p>

Second page

Code: Select all

<?php 
session_start(); 

echo '<pre>'; 
print_r($_SESSION); 
echo '</pre>'; 

echo $_SESSION['uname']; 
echo $_SESSION['ualias']; 

?>

Posted: Tue Mar 02, 2004 8:33 pm
by markl999
Then reboot your puter.
Seems a bit over the top when all you need to do is restart apache to reread the php.ini :o

Posted: Wed Mar 03, 2004 8:12 am
by cyberhawk
:oops: