i am going nuts = new session id just will not work

This is a discussion on i am going nuts = new session id just will not work within the PHP Language forums, part of the PHP Programming Forums category; Hi I have the following file: --myfile.php <?php if($s) { echo $s; session_id($s); session_start; echo 'your account ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-08-2006
windandwaves
 
Posts: n/a
Default i am going nuts = new session id just will not work

Hi

I have the following file:

--myfile.php
<?php
if($s) {
echo $s;
session_id($s);
session_start;
echo 'your account has been loaded, <a
href="index.php?PHPSESSID='.session_id().'">contin ue</a>.';
}
?>

I run it like this: myfile.php?s=abc

It does not matter how many times I load it, whenever I load my test file:

---test.php
<?php
session_start();
echo session_id()
?>

The same old session ID comes back (definitely not abc or any other
parameter that I pass using s). Having said that, in the link to index.php,
it provides the new session ID, but as soon as I reload the page, we are
back to normal.

The ONLY way to delete this old session ID is to delete the cookie from my
computer.

What am I doing wrong. It is driving me nuts!

TIA

- Nicolaas



Reply With Quote
  #2 (permalink)  
Old 01-08-2006
Geoff Berrow
 
Posts: n/a
Default Re: i am going nuts = new session id just will not work

Message-ID: <hV6wf.13488$vH5.695085@news.xtra.co.nz> from windandwaves
contained the following:

>The same old session ID comes back (definitely not abc or any other
>parameter that I pass using s). Having said that, in the link to index.php,
>it provides the new session ID, but as soon as I reload the page, we are
>back to normal.


What are you trying to do?

The session id will stay the same as long as the browser is open (within
the garbage collection time)

The session id serves as a reference to session variables which are
stored on the server. Therefore it is vitally important that it does
stay the same.

As you've found out the session id is stored in a cookie. You only have
to pass it by URL if you expect cookies to be turned off. Since the
cookie is only a memory cookie, most of the time you will be ok. If in
doubt you have to pass the session id or have it automatically enabled
on the server. The session id is available as a constant SID

If you want to store 'abc' by doing myfile.php?s=abc

<?php
session_start();

if(isset($_GET['s'])) {
echo $_GET['s']."<br>";
$_SESSION['s']=$_GET['s'];

echo "your account has been loaded, <a
href='index.php?".strip_tags(SID)."'>continue</a>.";
}
?>
You will find that the session id will not show unless cookies are
disabled

index.php must have session_start() as the first line
$_SESSION['s'] will contain your variable 'abc'
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 11:49 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0