Jump to content

[SOLVED] accessing session values???


faraz

Recommended Posts

hi,
i m new to PHP with a .net framework background, i want to use session in my app., is placed session_start() at the top of the page. in a function aa i used $_SESSION['id']='1', and in another function bb, i want to retrive session value by using $id = $_SESSION['id'], but it return nothing. any one know to access the session value??

Thanks

Faraz
Link to comment
https://forums.phpfreaks.com/topic/31457-solved-accessing-session-values/
Share on other sites

thanks for your reply.

i slightly changed the code, i used <?php ?> instead of <? ?> at the top, but now it is throwing warning:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at D:\wamp\www\hr\Test1.php:7)

is there any difference between the tags? bcoz i rad in a book that both are some.

is there any solution of this warning??

Thanks.
do you have any breaks before the top of the page... any whitespaces or anything... it should look like this:

[code=php:0]
<?php
session_start();
[/code]

exactly like that.... otherwise have this:

[/code]
<?php
session_start();
ob_start();

//rest of php

ob_end_flush();
[/code]

that will remove the error...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.