Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
| Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 1st, 2007, 07:41 AM
Registered User
 
Join Date: Apr 2007
Location: Dublin, , Ireland.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default PHP Sessions - why do I get a warning notice

Hello there,

I am hoping someone can clear something up about PHP Sessions.

If I want to grab the value of something that is already stored in a session and assign it to a variable as follows.

$user_id=$_SESSION['user_id'];

This only seems to work if a session_start(); statement is called in advance.

session_start();
$user_id=$_SESSION['user_id'];

//user_id will be assigned the value that is stored in the session

The major use of sessions within the application is to maintain the logged in status.

When I call session_start() I get an warning/notice to say that the session has aready been started and as a result the call to session_start(); has been ignored.

If I remove the line however I cannot get anything out of my session.

Does anyone have any ideas?

Regards,

Claire



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with sessions in php 4.3.11 ocabrera70 Beginning PHP 1 January 31st, 2008 04:28 AM
PHP Warning: PHP Startup: Unable to load dynamic l surendran Beginning PHP 1 May 29th, 2006 08:49 AM
chapter 15 cart.php Warning: mysql_fetch_array(): pink BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 July 19th, 2005 07:49 PM
tired of warning mesg in php script js_pandey PHP How-To 1 June 3rd, 2005 07:49 AM
PHP Sessions MrBillBill Beginning PHP 1 June 11th, 2004 09:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.