Get Session

QuestionsGet Session
JOEL GOMES asked 5 years ago

Good Morning
I have a webpage with autentication, i need to get session $_SESSION['username'] on grid, i have tried with the ["editoptions"] = array("defaultValue"=>'$username '); but no result, can someone help me please?

Thank you and great Job here

4 Answers
Abu Ghufran answered 5 years ago

This should work:
$col["editoptions"] = array("defaultValue"=>$_SESSION['username']);

Make sure session variable is there before grid code executes.

JOEL GOMES answered 5 years ago

Hey Abu thank you for your reply but still not working , if i do an echo $_SESSION['username'] it shows correctly, the session variables are working, i dont know why they dont work on the grid. Any other options?

this is my $col i think is everything correct
$col = array();
$col["title"] = "Creator";
$col["name"] = "CREATOR";
$col["editoptions"] = array("defaultValue"=>$_SESSION['username']);
$col["editable"] = false;
$col["editrules"] = array("required"=>true, "readonly"=>true);
$col["width"] = "60";
$col["align"] = "center";
$col["export"] = true;
$cols[] = $col;

Thank you one more time

Abu Ghufran answered 5 years ago

Please email complete grid code for review.
You can email at [email protected]

Abu Ghufran answered 5 years ago

The columns are constructed only once,and at that time session value is not present so you are getting null.
I would advice to set column value using on_update or on_insert event handler.
Refer demos/editing/custom-events.php

Your Answer

3 + 17 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?