Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session string length limitation?

Status
Not open for further replies.

Xaqte

IS-IT--Management
Oct 4, 2002
971
US
I have a situation where I need to save 5 strings to the session. However, each string exceeds 5000 characters in length.

I can set all 5 strings, but can only retrieve the first one.
So, is there a session string length limitation?


Thanks in advance,
X
 
To the best of my knowledge, there is not a limit to the size of a session store. By default, the session variables are store in a file on the server's filesystem, so you should have plenty of room.

You're not using some kind of alternate storage for your session variables, like a MySQL database, are you?

What's your testing method?

Do you have access to the directory on the server where the session files are stored?



Want the best answers? Ask the best questions! TANSTAAFL!
 
I'm not using any alternate type of data storage for my session variables.

The script I'm using this in gets called 5 times. During these times it keeps track of which run it is in (1 - 5) using session variables (which is working great). On the first run I set these session variables in a loop. After this loop I can write out the variables to the error log in insure they were written correctly.

In the following four runs:
[ul]
[li]I can only get the first two session variables.(again testing by writing them out to the error log).[/li]
[li]I have no problems in using the session variables to track the run.[/li]
[/ul]

In the meantime, I'm using a file for storage. I have no problems writing to it the same data, as well no problem reading the same date in the error log. Although this is an administrative script, I would prefer to use sessions (unless you have an even better recommendation).

Thanks again,
X
 
Can you access the directory where your session files are stored? If so, have you examined the file to insure the data was correctly written to it?

Also, are you referencing the session variables as direct references to elements in $_SESSION, or are you trying to copy these values to other variables?

If you're running a PHP version greater than 4.3.0, you're not using session_register at all, are you? And you do have register_globals set to "off", right?

I can't duplicate your error on my PHP 5.1.6 LAMP box. My test code looks like:

Code:
<?php
session_start();

$_SESSION['run_counter'] = 1;

$_SESSION['values'] = array
(
'1234567890123...01234567890
.
.
.
1234567890123...01234567890',
'1234567890123...01234567890
.
.
.
1234567890123...01234567890',
'1234567890123...01234567890
.
.
.
1234567890123...01234567890',
'1234567890123...01234567890
.
.
.
1234567890123...01234567890',
'1234567890123...01234567890
.
.
.
1234567890123...01234567890',
'1234567890123...01234567890
.
.
.
1234567890123...01234567890'
);

print '<html><body>
<a href="test_bar.php">click here</a><br><pre>';
print_r ($_SESSION['values']);
print '</pre></body></html>';
?>

(where, of course each horizontal "..." is more numbers and each vertical "..." is 48 more lines of numbers in my actual running code. I didn't think we needed all that in this thread)

and

Code:
<?php
session_start();

$_SESSION['run_counter']++;

print '<html><body><pre>';

print 'Run counter: ' . $_SESSION['run_counter'] . "\n";

print_r ($_SESSION['values']);

print '<pre></body></html>';
?>

The code works on my system.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top