473,385 Members | 1,922 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

Jan 8 '06 #1
1 1551
Message-ID: <hV********************@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
Jan 8 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jim Davidson | last post by:
Here's what I'm trying to do: I have a string with 30 numbers in it. I want to generate a random number between 0 an 30, go to that position in the string and get that number. Here is the code...
14
by: Paul Yanzick | last post by:
Hello, I am trying to develop a book tracking application for my capstone in school, and am running into a problem. The application is an ASP.Net application written in C#. The first page you...
12
by: Marty | last post by:
It seems all of the sudden that user controls that contain images are referencing image sources relative to the document that I drop the control on. This obviously does not work beacuase the...
8
by: Lloyd Sheen | last post by:
I have a problem with persisting the state of a control. It has several properties that can be determined but there is no event to indicate when the property changes. A postback occurs when one...
9
by: Greg Linwood | last post by:
I'm having difficulty understanding Session state in ASP.Net. It's almost embarrassing asking this as I've been using ASP since it was first released & it really shouldn't be this hard to use -...
10
by: tshad | last post by:
I have been using the default session state (InProc) and have found that I have been loosing my information after a period of time (normally 20 minutes). Is there anyway to find out how much...
43
by: davidkoree | last post by:
I mean not about cookie. Does it have something to do with operating system or browser plugin? I appreciate any help.
5
by: Shelly | last post by:
This ASPX/SqlServer stuff is driving me nuts. 1 - In a previous post I said I had four tables and all were showing up in Object Explorer (MS SQL Server Management Studio Express), but when I went...
28
BezerkRogue
by: BezerkRogue | last post by:
I have gotten my pages to work up to the final edit page. The code executes on load. Variables are passed by session but I get an SQL syntax error. I've tested the sp I'm calling and it works...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.