Jump to content


Photo

Sessions.


  • Please log in to reply
2 replies to this topic

#1 ReVeR

ReVeR
  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts

Posted 15 March 2006 - 11:51 PM

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:
$_SESSION['image_random_value']
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?


#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 16 March 2006 - 12:05 AM

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.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 ReVeR

ReVeR
  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts

Posted 18 March 2006 - 08:46 AM

hmm...well i still got the problem:
file 1: index.php
this file includes anohter file that sets teh session variable to some values, here is my call to get that variable:
<?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'];
I get the following error:
Notice: Undefined index: image_random_value in index.php ....
THis the the file that sets the session variable:
<?php 
$rand = rand(10000, 99999);
$_SESSION['image_random_value'] = md5($rand);
$image = imagecreate(60, 30);

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users