ReVeR Posted March 15, 2006 Share Posted March 15, 2006 Hello.I have a login scipr tnad i use sessions to store some data. Basicly i have 2 files.first file index.php has all the login stuff like forms etc, and the other files generates a random number to check for validity. A/w i need to store the random number after it was generated half way down the page in a session, so then when user presse login butotn, and the script at the top of the page runs, the number is still stored in the session.I use start_session() in both of my files, index.php and the file that generates the random number, but when i try to do this:[code]$_SESSION['image_random_value'][/code]in the index.php (the above value is created in the other file.) i get that image_random_value is undefined even though it is defined in the other file.Any ideas? Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 16, 2006 Share Posted March 16, 2006 post the other session that is set ok.Must not be set correctly try one hope one works good luck.Also make sure you got no white spaces or any html before the session_start();Is it set like this.$image_random_value=('$_SESSION['image_random_value']');or$image_random_value=('.$_SESSION['image_random_value'].');or$image_random_value=('".$_SESSION['image_random_value']."');its all guess work sorry.also post the error good luck. Quote Link to comment Share on other sites More sharing options...
ReVeR Posted March 18, 2006 Author Share Posted March 18, 2006 hmm...well i still got the problem:file 1: index.phpthis file includes anohter file that sets teh session variable to some values, here is my call to get that variable:[code]<?php session_start();include 'news/news.php';$news=new cnews;header("Cache-control: private");$errorMessage = '';$_SESSION['user']="Unknown";if (isset($_POST['txtUserId']) && isset($_POST['txtPassword'])) { $number = $_POST['txtNumber']; $image_random_value=$_SESSION['image_random_value'];[/code]I get the following error:[code]Notice: Undefined index: image_random_value in index.php ....[/code]THis the the file that sets the session variable:[code]<?php $rand = rand(10000, 99999);$_SESSION['image_random_value'] = md5($rand);$image = imagecreate(60, 30);[/code]Note do i need to start the session in the other file also or no?also the second file that makes the image is called half way down the page, and then when the form is submitted the variable is procced in the code above...any ideas where i went wrong?thx Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.